Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int a[7][7];
- int main()
- {
- int tn=1,tv=0,i,j,n;
- cin>>n;
- for(i=1;i<=n;i++)
- {
- if(i%2!=0)
- {
- for(j=1;j<=n;j++)
- {
- a[i][j]=tv;
- tn=tn+tv;
- tv=tn-tv;
- }
- }
- else
- {
- for(j=n;j>=1;j--)
- {
- a[i][j]=tv;
- tn=tn+tv;
- tv=tn-tv;
- }
- }
- }
- for(i=1;i<=n;i++)
- {
- for(j=1;j<=n;j++)
- {
- cout<<a[i][j]<<" ";
- }
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement