206-guruh talabasi
Uralov Doniyor
#include
#include
int search(int *k, int n, int key)
{
int temp;
for(int i=0;i
{
if(k[i]==key)
{
if(i==0)
return i;
temp=k[i];
k[i]=k[i-1];
k[i-1]=temp;
return i;
}
}
return -1;
}
int main()
{
int k[10];
int point;
//
system("chcp 1251");
//
system("cls");
for(int i=0;i<10;i++)
{
printf("k[%d] ni kiriting:",i);
scanf("%d",&k[i]);
}
point=search(k,10,3);
if(point==-1)
printf("massivda 3ga teng bo'lgan element yo'q!\n");
else
printf("%d indexli element 3ga teng \n", point);
getchar(); getchar();
return 0;
}
Natijasi: