Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4. int main() {
  5.  
  6.  
  7.  
  8. int lenght, i = 0;
  9. cout << "Enter number of lines" << endl;
  10. cin >> lenght;
  11. int* odd_positive = new int[lenght];
  12.  
  13.  
  14.  
  15. while (i < lenght ) {
  16. odd_positive[i] = i;
  17. i++;
  18. }
  19.  
  20.  
  21.  
  22. i = 1;
  23.  
  24.  
  25.  
  26. while (i < lenght ) {
  27. if (odd_positive[i] > 0) {
  28. cout << odd_positive[i] << "\t";
  29. }
  30. i += 2;
  31. }
  32.  
  33.  
  34.  
  35. i = 0;
  36. int height, j = 0;
  37. cout << "\n" << "Enter number of columns" << endl;
  38. cin >> height;
  39. int **duo_odd_positive= new int* [lenght];
  40.  
  41.  
  42.  
  43. while (i < lenght) {
  44. duo_odd_positive[i] = new int[height];
  45. i++;
  46. }
  47.  
  48.  
  49.  
  50. i = 0;
  51. j = 0;
  52.  
  53.  
  54.  
  55. while (i < lenght) {
  56. while (j < height) {
  57. duo_odd_positive[i][j] = j;
  58. j++;
  59. }
  60. j = 0;
  61. i++;
  62. }
  63.  
  64.  
  65.  
  66. i = 1;
  67. j = 0;
  68.  
  69.  
  70.  
  71. while (i < lenght) {
  72. cout << "Number of line: " << i << "\n";
  73. while (j < height) {
  74. if (duo_odd_positive[i][j] > 0) {
  75. cout << duo_odd_positive[i][j] << "\t";
  76. }
  77. j++;
  78. }
  79. j = 0;
  80. i += 2;
  81. cout << endl;
  82. }
  83.  
  84.  
  85.  
  86. system("pause");
  87.  
  88.  
  89.  
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement