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