E
engartte
hi all,
I did the solution on the following question,but no desired output is
acheived.if you know some way on,please show me with its comments.
-----------------------------------------------------
(Declare a two-dimensional array"a" of size 10 by 10 and
read 10 integers into a[0][0] to a[0][9].Then repeat the
insertion specified by an integer sequence nine times,and
store the results from a[1] to a[9].Finally,print the array.
Output Example:
1 2 3 4 5 6 7 8 9 10
2
3
4
5
6
7
8
9
10
1 2 3 4 5 6 7 8 9 10
2 1 3 4 5 6 7 8 9 10
1 3 2 4 5 6 7 8 9 10
3 2 4 1 5 6 7 8 9 10
2 4 1 5 3 6 7 8 9 10
4 1 5 3 6 2 7 8 9 10
1 5 3 6 2 7 4 8 9 10
5 3 6 2 7 4 8 1 9 10
3 6 2 7 4 8 1 9 5 10
6 2 7 4 8 1 9 5 10 3)
-------------------------------------------------------
I did as :
#include <stdio.h>
int main()
{
int a[10][10];
int i,j,k;
int x;
for(i=0; i<10; i++){
for(j=0; j<10; j++) a[j]=j+1;
}
for(i=0; i<10; i++){
for(j=0; j<i+1; j++){
x= a[j];
a[j] = a[j];
a[j]=x;
for(k=0; k<10; k++)printf("%d", a[j][k]);
printf("\n");
}
printf("\n");
}
return 0;
}
but,the output is compeletly different.
tanx in advance
I did the solution on the following question,but no desired output is
acheived.if you know some way on,please show me with its comments.
-----------------------------------------------------
(Declare a two-dimensional array"a" of size 10 by 10 and
read 10 integers into a[0][0] to a[0][9].Then repeat the
insertion specified by an integer sequence nine times,and
store the results from a[1] to a[9].Finally,print the array.
Output Example:
1 2 3 4 5 6 7 8 9 10
2
3
4
5
6
7
8
9
10
1 2 3 4 5 6 7 8 9 10
2 1 3 4 5 6 7 8 9 10
1 3 2 4 5 6 7 8 9 10
3 2 4 1 5 6 7 8 9 10
2 4 1 5 3 6 7 8 9 10
4 1 5 3 6 2 7 8 9 10
1 5 3 6 2 7 4 8 9 10
5 3 6 2 7 4 8 1 9 10
3 6 2 7 4 8 1 9 5 10
6 2 7 4 8 1 9 5 10 3)
-------------------------------------------------------
I did as :
#include <stdio.h>
int main()
{
int a[10][10];
int i,j,k;
int x;
for(i=0; i<10; i++){
for(j=0; j<10; j++) a[j]=j+1;
}
for(i=0; i<10; i++){
for(j=0; j<i+1; j++){
x= a[j];
a[j] = a[j];
a[j]=x;
for(k=0; k<10; k++)printf("%d", a[j][k]);
printf("\n");
}
printf("\n");
}
return 0;
}
but,the output is compeletly different.
tanx in advance