|
|
вернуться в форумwa on #3 Послано Shuhan 7 мар 2013 23:41 first i hav taken input of 2d array.........and then sorted them using merge sort..... i know there is a problem in my logic.......but i can't find it......help me find it please..... #include<stdio.h> int main() { int n,c,i,j,k,l,num; scanf("%d",&n); c=n-1; int ar[c][c]; num=1; for(i=c;i>=0;i--) { for(j=0;j<n-i;j++) { ar[i][j]=num; num++; } } for(j=1;j<=c;j++) { for(i=0;i<n-i;i++) { ar[i][j]=num; num++; } } for(i=0;i<n;i++) { for(j=0;j<n;j++) { printf("%d ",ar[i][j]); } printf("\n"); } return 0; }
Re: wa on #3 Hi, First of all, you don't need to sort the array. Read the Question properly, we just need to Reprint the Array in a Different Pattern of Diagnals, which is given in the Sample Output. |
|
|