Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1.  
  2.  
  3. // Project_Permutation_Nikolay_Georgiev.cpp : Defines the entry point for the console application.
  4. //
  5. //Nikolay Georgiev Georgiev
  6. //F92875
  7.  
  8.  
  9. #include "stdafx.h"
  10. #include <iostream>
  11. #include <cmath>
  12. #include <cstdbool>
  13.  
  14. using namespace std;
  15.  
  16.  
  17. //zadachi 1 i 2 избираме функция 3x
  18. //fillarray
  19.  
  20. int fillTheArray(int ** arr, int rows, int colls);
  21. int FillSecondRow(int ** arr, int rows, int colls);
  22. int printTheArray(int ** arr, int rows, int colls);
  23. bool IsInnection(int ** arr, int rows, int colls);
  24.  
  25.  
  26. int main()
  27. {
  28.  
  29.  
  30.  
  31.  
  32. int rows = 2;
  33. int colls;
  34. cout << "Enter number of columns: " << endl;
  35. cin >> colls;
  36. int ** arr = new int*[rows];
  37.  
  38. fillTheArray(arr, rows, colls);
  39. FillSecondRow(arr, rows, colls);
  40. printTheArray(arr, rows, colls);
  41. IsInnection(arr, rows, colls);
  42.  
  43. }
  44.  
  45.  
  46.  
  47.  
  48.  
  49. int fillTheArray(int ** arr, int rows, int colls) {
  50.  
  51. for (int i = 0; i < rows; i++)
  52. {
  53. arr[i] = new int[colls];
  54. }
  55.  
  56. for (int j = 0; j < colls; j++)
  57. {
  58.  
  59. cin >> arr[0][j];
  60.  
  61. }
  62.  
  63. return 0;
  64. }
  65.  
  66. int FillSecondRow(int ** arr, int rows, int colls) {
  67. int temp;
  68. for (int i = 0; i < rows-1; i++)
  69. {
  70. for (int j = 0; j < colls; j++)
  71. {
  72. arr[i + 1][j] = arr[i][j];
  73.  
  74. }
  75. }
  76.  
  77. for (int j = 0; j < colls; j++)
  78. {
  79. temp = arr[1][j];
  80. temp *= 3;
  81. arr[1][j] = temp;
  82. }
  83. return 0;
  84. }
  85.  
  86.  
  87.  
  88. int printTheArray(int ** arr, int rows, int colls) {
  89. for (int i = 0; i < rows; i++)
  90. {
  91. for (int j = 0; j < colls; j++)
  92. {
  93.  
  94. cout << arr[i][j] << " ";
  95. }
  96. cout << endl;
  97. }
  98. return 0;
  99. }
  100.  
  101.  
  102. bool IsInnection(int ** arr, int rows, int colls) {
  103.  
  104. for (int i = 0; i < rows; i++)
  105. {
  106. int temp;
  107. for (int j = 0; j < colls; j++)
  108. {
  109. temp = arr[i][j];
  110.  
  111. for (int k = 1; j < colls; j++)
  112. {
  113. if (temp == arr[i][k]) {
  114. cout << "Innection : true";
  115. return true;
  116. }
  117. else {
  118. cout << "Innection : false";
  119. return false;
  120. }
  121.  
  122. }
  123. }
  124. }
  125.  
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement