//Dev-C++ 5.11 (C)
#include
#include
#include
#include
int main(void)
{int i,n,*ar1,*ar2,min1,min2,b=1;
scanf("%d",&n);
ar1=(int*)malloc(n*sizeof(int));
ar2=(int*)malloc(n*sizeof(int));
srand(time(NULL));
printf("Array 1:\n");
for(i=0;i {ar1[i]=rand()%10;
printf("%d ",ar1[i]);}
printf("\n Array 2:\n");
for(i=0;i {ar2[i]=rand()%10;
printf("%d ",ar2[i]);}
min1=ar1[0];
min2=ar2[0];
for(i=1;i {if (min1>ar1[i])
min1=ar1[i];
if (min2>ar2[i])
min2=ar2[i];}
for(i=0;i if (min2==ar2[i])
{if(i+1==n)
{printf("Za massivom");
b=0;}
else
ar2[i+1]=min1;
break;}
if(b)
{printf("\n Fin array 2: \n");
for(i=0;i printf("%d ",ar2[i]);}
free(ar1);
free(ar2);
return 0;}
Пример ввода:
3
Пример вывода:
Array 1:
2 0 7
Array 2:
1 1 2
Fin array 2:
1 0 2