Advertisement
Guest User

var 2

a guest
Apr 2nd, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4. #include <cstdlib>
  5.  
  6. using namespace std;
  7.  
  8. void fill_matrix()
  9. {
  10.     unsigned int a[5][7];
  11.     for(unsigned int i = 0; i < 7; i++)
  12.         a[0][i] = 1;
  13.     for(unsigned int i = 0; i < 5; i++)
  14.         a[i][0] = 1;
  15.  
  16.     for(unsigned int i = 1; i < 5; i++)
  17.         for(unsigned int j = 1; j < 7; j++)
  18.             a[i][j] = (a[i-1][j] + a[i][j-1]) % 10;
  19.  
  20.     for(unsigned int i = 0; i < 5; i++)
  21.     {
  22.         for(unsigned int j = 0; j < 7; j++)
  23.             cout << a[i][j] << " ";
  24.         cout << "\n";
  25.     }
  26. }
  27.  
  28. void fii(unsigned int n)
  29. {
  30.     for(unsigned int a = n; a * a > n; --a)
  31.     {
  32.         if(n % a == 0)
  33.         {
  34.             unsigned int b = n / a;
  35.             cout << "(" << a << " " << b << ") ";
  36.         }
  37.     }
  38. }
  39.  
  40. void elim_neg()
  41. {
  42.     char sir[101];
  43.     cin.get(sir, 101);
  44.     cin.get();
  45.     for(unsigned int i = 1; i < strlen(sir); ++i)
  46.     {
  47.         if(sir[i-1] == '-' && sir[i] >= '0' && sir[i] <= '9')
  48.         {
  49.             while((sir[i] >= '0' && sir[i] <= '9') || sir[i] == ',')
  50.                 strcpy(sir + i, sir + 1 + i);
  51.             strcpy(sir + i, sir + 1 + i);
  52.             strcpy(sir - 1 + i, sir + i);
  53.         }
  54.     }
  55.     cout << sir;
  56. }
  57.  
  58. void max_3_20()
  59. {
  60.     unsigned int max1, max2, max3, x;
  61.     max1 = max2 = max3 = 0;
  62.     ifstream f("bac.in");
  63.     while (f >> x)
  64.     {
  65.         if (x % 100 == 20)
  66.         {
  67.             if (x > max1)
  68.                 max1 = x;
  69.             else if (x > max2)
  70.                 max2 = x;
  71.             else if (x > max3)
  72.                 max3 = x;
  73.         }
  74.     }
  75.     cout << max3 << " " << max2 << " " << max1;
  76. }
  77.  
  78. int main()
  79. {
  80.     fill_matrix();
  81.     fii(100);
  82.     elim_neg();
  83.     max_3_20();
  84.     return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement