View Code of Problem 51

#incliude <iostream>
using namespace std;

int main(){
  int n,sum=0;
  cin>>n;
  int m[n][n];
  for(int j=0;j<n;j++){	
    for(int k=0;k<n;k++){    
      scanf("%d",&m[j][k]);
    }
  }
  
  for(int j=0;j<n;j++){	
    for(int k=0;k<j+1;k++){    
      sum+=m[j][k];
    }
  }
  
  printf("%d",sum);
  
  return 0;
}
/*
Main.cc:1:2: error: invalid preprocessing directive #incliude
 #incliude <iostream>
  ^
Main.cc: In function 'int main()':
Main.cc:6:3: error: 'cin' was not declared in this scope
   cin>>n;
   ^
Main.cc:10:26: error: 'scanf' was not declared in this scope
       scanf("%d",&m[j][k]);
                          ^
Main.cc:20:18: error: 'printf' was not declared in this scope
   printf("%d",sum);
                  ^
*/

Double click to view unformatted code.


Back to problem 51