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