Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I.
- 1.a
- 2.d
- 3.c
- 4.b
- 5.b
- II.
- 1.
- a) -1 21
- b) 12345 12346
- c)
- #include <iostream>
- using namespace std;
- int main() {
- int n, s, c1, c2;
- cin >> n;
- s = 1;
- c1 = n % 10;
- n = n / 10;
- c2 = n % 10;
- if (c1 == c2) s = 0;
- else if (c1 < c2) s = -1;
- while ((c1 - c2) * s > 0 && n > 9) {
- c1 = n % 10;
- n = n / 10;
- c2 = n % 10;
- }
- cout << s << " " << n;
- return 0;
- }
- d)
- #include <iostream>
- using namespace std;
- int main() {
- int n, s, c1, c2;
- cin >> n;
- s = 1;
- c1 = n % 10;
- n = n / 10;
- c2 = n % 10;
- if (c1 == c2) s = 0;
- else if (c1 < c2) s = -1;
- if ((c1 - c2) s > 0 && n > 9) {
- c1 = n % 10;
- n = n / 10;
- c2 = n % 10;
- }
- do {
- c1 = n % 10;
- n = n / 10;
- c2 = n % 10;
- } while ((c1 - c2) s > 0 && n > 9);
- cout << s << " " << n;
- return 0;
- }
- 2.
- struct polinom{int grad;
- int coeficient[100];
- }p;
- 3.
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- char s[21], t[21];
- int i, j;
- cin >> s;
- strcpy(t, "aeiouAEIOU");
- for (i = 0; i < strlen(s); i++)
- if (strchr("aeiouAEIOU", s[i]) != 0)
- for (j = 0; j < strlen(t); j++)
- if (s[i] == t[j])
- strcpy(t + j, t + j + 1);
- cout << t;
- return 0;
- }
- III.
- 1.
- int factori(int n, int m) {
- int ap1[100001] = {
- 0
- }, ap2[100001] = {
- 0
- }, d, p, maxi = 2e-9, cate = 0, i;
- d = 2;
- while (n > 1) {
- p = 0;
- while (n % d == 0) {
- ++p;
- n /= d;
- }
- if (p)
- ap1[d] = p;
- maxi = max(maxi, d);
- ++d;
- if (n > 1 && d * d > n)
- d = n;
- }
- d = 2;
- while (m > 1) {
- p = 0;
- while (m % d == 0) {
- ++p;
- m /= d;
- }
- if (p)
- ap2[d] = p;
- maxi = max(maxi, d);
- ++d;
- if (m > 1 && d * d > m)
- d = m;
- }
- for (i = maxi; i > 1; i--)
- if (ap1[i] == ap2[i] && ap1[i] != 0)
- cate++;
- return cate;
- }
- 2.
- #include <iostream>
- using namespace std;
- int main() {
- int a[21][21], i, j, n, c;
- cin >> n;
- for (i = 1; i <= n; i++) {
- c = i;
- for (j = 1; j <= n - i + 1; j++) {
- a[i][j] = c;
- a[n - j + 1][n - i + 1] = c;
- c++;
- }
- }
- for (i = 1; i <= n; i++) {
- for (j = 1; j <= n; j++)
- cout << a[i][j] << " ";
- cout << "\n";
- }
- return 0;
- }
- 3.
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin("bac.txt");
- int main() {
- int x, i, f, cate = 0, ok = 0, maxi;
- while (fin >> x) {
- cate++;
- if (x >= 0) {
- if (ok == 0) {
- i = cate;
- ok = 1;
- }
- f = cate;
- }
- }
- maxi = max(cate - i + 1, f);
- cout << maxi;
- return 0;
- }
RAW Paste Data