Advertisement
DorSen

Bilet 18

Jan 24th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. Билет 18
  2. #include <iostream>
  3. #include <cmath>
  4. #include <math.h>
  5. int main ()
  6. {
  7.     using namespace std;
  8.     const int N = 5;
  9.     const int M = N * 2;
  10.     int A[N] = { -4, -2, 0, 9, 9 };
  11.     int B[N] = { 1, 3, 6, 8, 10 };
  12.     int arr[M];
  13.    int i = 0, j = 0, k = 0;
  14.     while (i < N && j < N)
  15.     {
  16.         if (A[i] < B[j])
  17.         {
  18.             arr[k] = A[i];
  19.             i++;
  20.         }
  21.         else
  22.         {
  23.             arr[k] = B[j];
  24.             j++;
  25.         }
  26.         k++;
  27.     }
  28.     for (; i < N; i++, k++)
  29.         arr[k] = A[i];
  30.     for (; j < N; j++, k++)
  31.         arr[k] = B[j];
  32.  
  33.     for (int i = 0; i < M; i++)
  34.       cout << arr[i] << " ";
  35.    cout << endl;
  36. }
  37.  
  38. #include <stdio.h>
  39. #include<math.h>
  40.  
  41. int main()
  42. {
  43.     int a = 590155069;
  44.     int b, i = 0, k;
  45.  
  46.     b = a;
  47.  
  48.     while (b > 1) {  // считает кол-во символов в числе
  49.         b /= 10;
  50.         i++;
  51.     }   i--;
  52.     k = pow(10, i);
  53.  
  54.     while (k) {
  55.         b = a / k;
  56.  
  57.         if (b != 5 && b != 0) printf("%d", b);
  58.         a -= b * k;
  59.         k /= 10;
  60.     }
  61.  
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement