fork download
  1. package Streams;
  2.  
  3. import java.util.*;
  4. class answer{
  5. private static Scanner sc;
  6. public static void main(String []args){
  7. sc = new Scanner(System.in);
  8. int n;
  9. char a[][]=new char [1000][1000];
  10. n=sc.nextInt();
  11. for(int i=0;i<n;i++){
  12. for(int j=0;j<n;j++){
  13. a[i][j]=sc.next().charAt(0);
  14. }
  15. }
  16. /*to print the main diagonal*/
  17. for(int i=0;i<n;i++){
  18. System.out.print(a[i][i]+" ");
  19. }
  20. System.out.println();
  21. /*to print the reserve diagonal*/
  22. for(int i=0;i<n;i++){
  23. System.out.print(a[i][n-i-1]+" ");
  24. }
  25. }
  26. }
  27.  
  28.  
Runtime error #stdin #stdout #stderr 0.11s 321024KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error: Could not find or load main class answer