-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create 2ndoct_zigzag_yash2001340.cpp
I created zigzag showing numbers code please accept my merge and add it in your repository
- Loading branch information
1 parent
dfaf5dc
commit 7a1e72f
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int row,column; | ||
cin>>row>>column; | ||
int sum=(row+column+1)/2; | ||
for(int i=1;i<=row;i++) | ||
{ | ||
for(int j=1;j<=column;j++) | ||
{ | ||
if(i==j) | ||
{ | ||
cout<<i; | ||
} | ||
else if(j==(sum+1-i+1)|| j==(sum+1+i-1)) | ||
{ | ||
cout<<j; | ||
} | ||
else{ | ||
cout<<" "; | ||
} | ||
} | ||
cout<<endl; | ||
} | ||
|
||
return 0; | ||
} |