Vlad5080

Bilet_27

Jan 24th, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. void ex2() {
  7.     int i, chislo, n, x = 0;
  8.     do
  9.     {
  10.         cout << " Введите количество чисел(n > 0) :\t";
  11.         cin >> n;
  12.     } while (n <= 0);
  13.     int* mas = new int[n];
  14.     for (i = 0; i < n; i++)
  15.     {
  16.         cout << i + 1 << " элемент : \t";
  17.         cin >> mas[i];
  18.     }
  19.     cout << " Введите число для проверки ";
  20.     cin >> chislo;
  21.     cout << " На позиуиях: " << endl;
  22.     for (i = 0; i < n; i++)
  23.     {
  24.         if (mas[i] == chislo){
  25.         x++;
  26.         cout << i+1 << " ";
  27.         }
  28.            
  29.     }
  30.     cout << " Данное число встречается в последовательности « << x << » раз(а) " << endl;
  31. }
  32.  
  33. void ex1() {
  34.     int x, y, z, temp;
  35.  
  36.     cout << "x= ";
  37.     cin >> x;
  38.  
  39.     cout << "y= ";
  40.     cin >> y;
  41.  
  42.     z = x + y;
  43.  
  44.     int* arr1 = new int[x];
  45.     int* arr2 = new int[y];
  46.     int* arr3 = new int[z];
  47.  
  48.     for (int i = 0; i < x; i++) {
  49.         cin >> arr1[i];
  50.     }
  51.     for (int i = x - 1; i >= 1; i--) {
  52.         for (int j = 0; j < i; j++) {
  53.             if (arr1[j] > arr1[j + 1]) {
  54.                 temp = arr1[j];
  55.                 arr1[j] = arr1[j + 1];
  56.                 arr1[j + 1] = temp;
  57.             }
  58.         }
  59.     }
  60.  
  61.     temp = 0;
  62.  
  63.     for (int i = 0; i < y; i++) {
  64.         cin >> arr2[i];
  65.     }
  66.     for (int i = y - 1; i >= 1; i--) {
  67.         for (int j = 0; j < i; j++) {
  68.             if (arr2[j] > arr2[j + 1]) {
  69.                 temp = arr2[j];
  70.                 arr2[j] = arr2[j + 1];
  71.                 arr2[j + 1] = temp;
  72.             }
  73.         }
  74.     }
  75.  
  76.     temp = 0;
  77.  
  78.     for (int i = 0; i < z; i++) {
  79.         if (i < x) {
  80.             arr3[i] = arr1[i];
  81.         }
  82.         else {
  83.             arr3[i] = arr2[i - x];
  84.         }
  85.     }
  86.     for (int i = z - 1; i >= 1; i--) {
  87.         for (int j = 0; j < i; j++) {
  88.             if (arr3[j] > arr3[j + 1]) {
  89.                 temp = arr3[j];
  90.                 arr3[j] = arr3[j + 1];
  91.                 arr3[j + 1] = temp;
  92.             }
  93.         }
  94.     }
  95.  
  96.     for (int i = 0; i < z; i++) {
  97.         cout << arr3[i] << " ";
  98.     }
  99.     cout << endl;
  100.  
  101.     delete arr1;
  102.     delete arr2;
  103.     delete arr3;
  104.  
  105. }
  106.  
  107. int main() {
  108.     setlocale(0, "");
  109.  
  110.     //  ex1();
  111.     // ex2();
  112.  
  113.  
  114.  
  115.     system("pause");
  116.     return 0;
  117. }
Advertisement
Add Comment
Please, Sign In to add comment