GerexD

gy33/4,6

Apr 8th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. gy33_4
  2.  
  3. #include <iostream>
  4. #include <cmath>
  5.  
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. int a[50][50],n,m;
  12. cout<<"N ";cin>>n;
  13. cout<<"M ";cin>>m;
  14.  
  15. int p=1;
  16. for(int i=1;i<=n;i++)
  17. {
  18. for(int j=1;j<=m;j++)
  19. {a[i][j]=p*p;
  20. p=p+2;}
  21. else
  22. p=p+2;
  23. }
  24.  
  25. for(int i=1;i<=n;i++)
  26. {
  27. for(int j=1;j<=m;j++)
  28. cout<<a[i][j]<<" ";
  29. cout<<endl;
  30. }
  31.  
  32. return 0;
  33. }
  34. +++++++++++++++++++++++++++++++++++++++++++++
  35. gy33_6
  36.  
  37. #include <iostream>
  38.  
  39. using namespace std;
  40.  
  41. int main()
  42. {
  43. int a[50][50],n,m;
  44. cout<<"N ";cin>>n;
  45. cout<<"M ";cin>>m;
  46.  
  47. for(int i=1;i<=n;i++)
  48. {
  49. for(int j=1;j<=m;j++)
  50. if(i%2==1)
  51. a[i][j]=1;
  52. else
  53. a[i][j]=2;
  54. }
  55. for(int i=1;i<=n;i++)
  56. {
  57. for(int j=1;j<=m;j++)
  58. cout<<a[i][j]<<" ";
  59. cout<<endl;
  60.  
  61. }
  62.  
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment