Advertisement
Guest User

123

a guest
Oct 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5.  
  6. int main() {
  7.    
  8.     int a[100][100];
  9.    
  10.    
  11.    
  12.     int n,t=0,t1=0;
  13.    
  14.    
  15.    
  16.    
  17.     for(int i = 0 ; i<n; i++){
  18.    
  19.         /* Right */
  20.         for(int j = 0; j<n-1; j++){
  21.            
  22.             a[0+t][j-t1] = i;
  23.  
  24.         }          
  25.        
  26.        
  27.         /* \Right */
  28.  
  29.  
  30.         /* Down */
  31.         for(int j = 0; j<n; j++){
  32.            
  33.             a[j+t1][(n-1)-t] = i;
  34.            
  35.         }
  36.         /* \Down */
  37.        
  38.         /* Left */
  39.         for(int j = n-1; j>=0; j--){
  40.            
  41.             a[(n-1)-t][(j-1)-t1] = i;
  42.            
  43.         }
  44.         /* \Left */
  45.  
  46.         /* Up */
  47.         for(int j = n-1; j>0+t; j--){
  48.            
  49.             a[j-1][0+t] = i;
  50.            
  51.         }
  52.         /* \Up */
  53.        
  54.         t++;
  55.         t1++;
  56.     }
  57.    
  58.     for(int i = 0; i<n; i++){
  59.         for(int j = 0; j<n; j++){
  60.            
  61.             cout<<a[i][j]<<" ";
  62.            
  63.         }
  64.         cout<<endl;
  65.     }
  66.    
  67.    
  68.     system("pause");
  69.    
  70.     return 0;
  71.    
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement