Advertisement
Dizzy3113

Untitled

Jan 5th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int a[51][51], n,m,nr=1,i,j;
  8. cin>>n>>m;
  9. for(i=1; i<=n; i++)
  10. {
  11.  
  12. for(j=1; j<=m; j++)
  13. {
  14. a[i][j]=nr;
  15. nr++;
  16. }
  17. i++;
  18. for(j=m; j>=1; j--)
  19. {
  20. a[i][j]=nr;
  21. nr++;
  22. }
  23. }
  24.  
  25.  
  26.  
  27.  
  28. for(i=1; i<=n; i++)
  29. {
  30. for(j=1; j<=m; j++)
  31. cout<<a[i][j]<<" ";
  32. cout<<endl;
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement