fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. void show(int count);
  4. int main(){
  5. const int length=7;
  6. int arr[length][length]={{1,2,3,0,1,1,2},{4,5,6,1,6,1,6},{7,8,9,2,3,2,3},{1,5,8,4,5,5,8},{1,2,3,4,5,4,5},{1,5,8,4,5,5,8},{4,5,6,1,6,1,6}};
  7. for(int i=0;i<length;i++){
  8. for(int j=0;j<length;j++)
  9. cout<<arr[i][j]<<" ";
  10. cout<<endl;
  11. }
  12. for(int i=0;i<length;i++){
  13. show(length-i-1);
  14. for(int j=0;j<=i;j++){
  15. cout<<arr[i-j][j]<<" ";
  16. }
  17. cout<<endl;
  18. }
  19. cout<<endl<<endl;
  20. return 0;
  21. }
  22. void show(int count){
  23. for(int i=0;i<count;i++)
  24. cout<<" ";
  25. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
1 2 3 0 1 1 2 
4 5 6 1 6 1 6 
7 8 9 2 3 2 3 
1 5 8 4 5 5 8 
1 2 3 4 5 4 5 
1 5 8 4 5 5 8 
4 5 6 1 6 1 6 
      1 
     4 2 
    7 5 3 
   1 8 6 0 
  1 5 9 1 1 
 1 2 8 2 6 1 
4 5 3 4 3 1 2