include stdio include stdlib define int main int argc char argv srand

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
#include <stdlib.h>
#define N 4
int main(int argc, char *argv[])
{srand(time(NULL));
int mas[N][N],i,j,tmp,k;
//C&O a mass
for(i=0;i<N;++i)
for(j=0;j<N;++j)
mas[i][j]=rand()%10;
for(i=0;i<N;++i)
{for(j=0;j<N;++j)
printf("%d ",mas[i][j]);
printf("\n");
}
printf("\n\n\n\n");
//job
for(i=0;i<=1;i++)
for(k=0;k<N;k++)
for(j=0;j<N-1;j++)
if(i==1)
{if(mas[i][j]<mas[i][j+1])
{tmp=mas[i][j];
mas[i][j]=mas[i][j+1];
mas[i][j+1]=tmp;
}
}
//out
for(i=0;i<N;++i)
{for(j=0;j<N;++j)
printf("%d ",mas[i][j]);
printf("\n");
}
system("PAUSE");
return 0;
}