View Code of Problem 45

#include <stdio.h>
int main()
{
	int i,j,n;
  	scanf("%d",&n);
  	char a[n][n];
  	for(int i=0;i<n;++i)
          for(int j=0;j<n;++j)
          scanf("%d",a[i][j);
        
          for(int i=0;i<n;++i)
          for(int j=0;j<n;++j)
              if(j==n-1)
                   printf("%d\n",a[j[i]);
               else
                                   printf("%d ",a[j][i];
                          
  	
  
  
  
  
  
 
 
}
/*
Main.c: In function 'main':
Main.c:9:28: error: expected ']' before ')' token
           scanf("%d",a[i][j);
                            ^
Main.c:9:28: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
Main.c:14:37: error: subscripted value is neither array nor pointer nor vector
                    printf("%d\n",a[j[i]);
                                     ^
Main.c:14:40: error: expected ']' before ')' token
                    printf("%d\n",a[j[i]);
                                        ^
Main.c:16:56: error: expected ')' before ';' token
                                    printf("%d ",a[j][i];
                                                        ^
Main.c:26:1: error: expected ';' before '}' token
 }
 ^
Main.c:4:8: warning: unused variable 'j' [-Wunused-variable]
  int i,j,n;
        ^
Main.c:4:6: warning: unused variable 'i' [-Wunused-variable]
  int i,j,n;
      ^
*/

Double click to view unformatted code.


Back to problem 45