Advertisement
cyter

code_clash_thursday

Sep 6th, 2018
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. //g++  5.4.0
  2.  
  3. #include <iostream>
  4. #include <string>
  5. using std::string;
  6. using std::cout;
  7. using std::cin;
  8. /*
  9. given an N by N array of chars as input string
  10. output the diagonal strings
  11.  
  12. example
  13. for the following input
  14.     N=4
  15.     mooa
  16.     danl
  17.     atis
  18.     icsn
  19.  
  20. the output would be
  21.  
  22.     output
  23.     main anti
  24. */
  25. int main()
  26. {
  27.     int N;
  28.     cin>>N; cin.ignore();
  29.     string line(""), diag1(""), diag2("");
  30.     for(int i = 0; i < N; i++){
  31.         string line;        
  32.         cin>>line;
  33.         cin.ignore();
  34.         diag1 += line[i];
  35.         diag2 += line[(N-i)-1];        
  36.     } cout<< diag1<<" "<<diag2 <<'\n';
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement