john2323

BAC 2021 TEST 2 ANTRENAMENT INFO

Mar 3rd, 2021
1,095
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. I.
  2. 1.a
  3. 2.d
  4. 3.c
  5. 4.b
  6. 5.b
  7.  
  8. II.
  9. 1.
  10. a) -1 21
  11. b) 12345 12346
  12. c)
  13. #include <iostream>
  14.  
  15. using namespace std;
  16.  
  17. int main() {
  18.   int n, s, c1, c2;
  19.   cin >> n;
  20.   s = 1;
  21.   c1 = n % 10;
  22.   n = n / 10;
  23.   c2 = n % 10;
  24.   if (c1 == c2) s = 0;
  25.   else if (c1 < c2) s = -1;
  26.   while ((c1 - c2) * s > 0 && n > 9) {
  27.     c1 = n % 10;
  28.     n = n / 10;
  29.     c2 = n % 10;
  30.   }
  31.   cout << s << " " << n;
  32.   return 0;
  33. }
  34.  
  35. d)
  36. #include <iostream>
  37.  
  38. using namespace std;
  39.  
  40. int main() {
  41.   int n, s, c1, c2;
  42.   cin >> n;
  43.   s = 1;
  44.   c1 = n % 10;
  45.   n = n / 10;
  46.   c2 = n % 10;
  47.   if (c1 == c2) s = 0;
  48.   else if (c1 < c2) s = -1;
  49.   if ((c1 - c2) s > 0 && n > 9) {
  50.     c1 = n % 10;
  51.     n = n / 10;
  52.     c2 = n % 10;
  53.   }
  54.   do {
  55.     c1 = n % 10;
  56.     n = n / 10;
  57.     c2 = n % 10;
  58.   } while ((c1 - c2) s > 0 && n > 9);
  59.   cout << s << " " << n;
  60.   return 0;
  61. }
  62. 2.
  63. struct polinom{int grad;
  64.                int coeficient[100];
  65.                }p;
  66.  
  67. 3.
  68. #include <bits/stdc++.h>
  69.  
  70. using namespace std;
  71.  
  72. int main() {
  73.   char s[21], t[21];
  74.   int i, j;
  75.   cin >> s;
  76.   strcpy(t, "aeiouAEIOU");
  77.   for (i = 0; i < strlen(s); i++)
  78.     if (strchr("aeiouAEIOU", s[i]) != 0)
  79.       for (j = 0; j < strlen(t); j++)
  80.         if (s[i] == t[j])
  81.           strcpy(t + j, t + j + 1);
  82.  
  83.   cout << t;
  84.   return 0;
  85. }
  86.  
  87. III.
  88. 1.
  89. int factori(int n, int m) {
  90.   int ap1[100001] = {
  91.     0
  92.   }, ap2[100001] = {
  93.     0
  94.   }, d, p, maxi = 2e-9, cate = 0, i;
  95.   d = 2;
  96.   while (n > 1) {
  97.     p = 0;
  98.     while (n % d == 0) {
  99.       ++p;
  100.       n /= d;
  101.     }
  102.     if (p)
  103.       ap1[d] = p;
  104.     maxi = max(maxi, d);
  105.     ++d;
  106.     if (n > 1 && d * d > n)
  107.       d = n;
  108.   }
  109.  
  110.   d = 2;
  111.   while (m > 1) {
  112.     p = 0;
  113.     while (m % d == 0) {
  114.       ++p;
  115.       m /= d;
  116.     }
  117.     if (p)
  118.       ap2[d] = p;
  119.     maxi = max(maxi, d);
  120.     ++d;
  121.     if (m > 1 && d * d > m)
  122.       d = m;
  123.   }
  124.   for (i = maxi; i > 1; i--)
  125.     if (ap1[i] == ap2[i] && ap1[i] != 0)
  126.       cate++;
  127.   return cate;
  128. }
  129.  
  130. 2.
  131. #include <iostream>
  132.  
  133. using namespace std;
  134.  
  135. int main() {
  136.   int a[21][21], i, j, n, c;
  137.   cin >> n;
  138.   for (i = 1; i <= n; i++) {
  139.     c = i;
  140.     for (j = 1; j <= n - i + 1; j++) {
  141.       a[i][j] = c;
  142.       a[n - j + 1][n - i + 1] = c;
  143.       c++;
  144.     }
  145.   }
  146.   for (i = 1; i <= n; i++) {
  147.     for (j = 1; j <= n; j++)
  148.       cout << a[i][j] << " ";
  149.     cout << "\n";
  150.   }
  151.   return 0;
  152. }
  153.  
  154. 3.
  155. #include <bits/stdc++.h>
  156.  
  157. using namespace std;
  158. ifstream fin("bac.txt");
  159. int main() {
  160.   int x, i, f, cate = 0, ok = 0, maxi;
  161.   while (fin >> x) {
  162.     cate++;
  163.     if (x >= 0) {
  164.       if (ok == 0) {
  165.         i = cate;
  166.         ok = 1;
  167.       }
  168.       f = cate;
  169.     }
  170.   }
  171.  
  172.   maxi = max(cate - i + 1, f);
  173.   cout << maxi;
  174.   return 0;
  175. }
  176.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×