fork download
  1. #include <stdio.h>
  2. #define SIZE 1000
  3. int main(void) {
  4. int mat[SIZE][SIZE];
  5. int n,i,j;
  6. //read matrix
  7. scanf("%d", &n);
  8. for(i=0;i<n;i++){
  9. for(j=0;j<n;j++){
  10. scanf("%d", &mat[i][j]);
  11. }
  12. }
  13. //execute problems
  14. for(i=0;i<n;i++){
  15. for(j=0;j<n;j++){
  16. if(i<j){
  17. mat[i][j]=mat[i][j]+mat[j][i];
  18. }else{
  19. mat[i][j]=0;
  20. }
  21.  
  22. }
  23. }
  24. //print output
  25. for(i=0;i<n;i++){
  26. for(j=0;j<n;j++){
  27. printf("%d", &mat[i][j]);
  28. if(j==(n-1)){
  29. printf("\n");
  30. }else{
  31. printf(" ");
  32. }
  33. }
  34. }
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0s 13216KB
stdin
5
1 2 3 4 5
7 8 4 2 3
4 5 6 6 3
2 5 3 7 8
3 4 5 1 7
stdout
-870581040 -870581036 -870581032 -870581028 -870581024
-870577040 -870577036 -870577032 -870577028 -870577024
-870573040 -870573036 -870573032 -870573028 -870573024
-870569040 -870569036 -870569032 -870569028 -870569024
-870565040 -870565036 -870565032 -870565028 -870565024