Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- int main() {
- int a[100][100];
- int n,t=0,t1=0;
- for(int i = 0 ; i<n; i++){
- /* Right */
- for(int j = 0; j<n-1; j++){
- a[0+t][j-t1] = i;
- }
- /* \Right */
- /* Down */
- for(int j = 0; j<n; j++){
- a[j+t1][(n-1)-t] = i;
- }
- /* \Down */
- /* Left */
- for(int j = n-1; j>=0; j--){
- a[(n-1)-t][(j-1)-t1] = i;
- }
- /* \Left */
- /* Up */
- for(int j = n-1; j>0+t; j--){
- a[j-1][0+t] = i;
- }
- /* \Up */
- t++;
- t1++;
- }
- for(int i = 0; i<n; i++){
- for(int j = 0; j<n; j++){
- cout<<a[i][j]<<" ";
- }
- cout<<endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement