Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void constr(int &n, int &m, int a[101][101])
  6. {
  7. int i, j, x=1;
  8. cout<<"m = ";
  9. cin>>m;
  10. cout<<"n = ";
  11. cin>>n;
  12. for(i=1; i<=m; i++)
  13. {
  14. if(i%2!=0)
  15. for(j=1; j<=n; j++)
  16. {
  17. a[i][j]=x;
  18. x++;
  19. }
  20. else
  21. for(j=n; j>=1; j--)
  22. {
  23. a[i][j]=x;
  24. x++;
  25. }
  26. }
  27. }
  28.  
  29. void afis(int n, int m, int a[101][101])
  30. {
  31. int i, j;
  32. for(i=1; i<=m; i++)
  33. {
  34. for(j=1; j<=n; j++)
  35. cout<<a[i][j]<<" ";
  36. cout<<endl;
  37. }
  38. }
  39.  
  40. int main()
  41. {
  42. int m, n, a[101][101];
  43. constr(n, m, a);
  44. cout<<endl;
  45. afis(n, m, a);
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement