2–variant. A massiv berilgan, A massivdagi elementlar orasidan 30 dan katta elementlarni toping.
Dastur kodi:
Indeksli saralash:
#include
#include
using namespace std;
void insertSort(int a[], int N)
{
int x;
int i, j;
for ( i=0; i < N; i++)
{
x = a[i];
for ( j=i-1; j>=0 && a[j] > x; j--)
a[j+1] = a[j];
a[j+1] = x;
} }
main ()
{
int i, n, mas[1000],k;
cout<>n;
cout<<"Massiv elementlarini kiriting:"<
for (i=0; i
cin>>mas[i];
insertSort(mas,n);
cout<<"30 dan katta Saralangan massiv:"<
for(i=0; i
{if(mas[i]>30)
cout<
else cout<<"";
}
getch();
return 0;
}
Do'stlaringiz bilan baham: |