Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
3.1 kB
1
Indexable
Never
#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;

long long factorial(int a) {
	long long fr = 1;
	while (a > 0) {
		fr *= a;
		a--;
	}
	return fr;
}

double average(int a1, int b) {
	double ver = (a1 + b) / (double)2;
	return ver;
}

int f1(int a2) {
	int dist = 0;
	while (a2 > 0) {
		a2 /= 10;
		dist += 1;
	}
	std::cout << dist;
	return dist;
}

double distance(double x1, double x2, double y1, double y2) {
	double res;
	double l1, l2;
	l1 = x1 - x2;
	l2 = y1 - y2;
	res = sqrt((l1 * l1) + (l2 * l2));
	std::cout << res;
	return res;
}


bool one(int a3) {
	int i = 2;
	while (i < a3) {
		if (a3 % i == 0) {
			std::cout << "NO";
			return false;
		}
		else {
			i++;
		}
	}
	std::cout << "YES";
	return true;
}

bool prostoe(int a4) {
	int i = 2;
	while (i <= sqrt(a4)) {
		if (a4 % i == 0) {
			return false;
		}
		i++;
	}
	return true;
}



int e(int b2) {
	int y = 2;
	int i = 0;
	while (y <= (b2 / 2)) {
		if (b2 % y == 0) {
			i++;
			std::cout << y << endl;
		}
		y++;
	}
	return i;
}

int s(int a6, int b3) {
	int summ = 0;
	bool h = 0;
	int i;
	while (a6 <= b3) {
		i = 2;
		h = 0;
		while (i <= sqrt(a6)) {
			if (a6 % i == 0)
				h = 1;
			i++;
		}

		if (h == 0) {
			summ += a6;
			std::cout << a6 << " ";
		}
		a6++;
	}
	return summ;
}

int r(int a7) {
	int i = 0;
	while (a7 > 0) {
		std::cout << a7 % 10;
		a7 /= 10;
		i++;
	}
	return i;
}

long POW(int d, int s) {
	int pow = 1;
	while (s > 0) {
		pow *= d;
		s--;
	}
	return pow;
}

string sr(string str) {
	int i = 0;
	bool iz = 0;
	while (i < str.size()) {
		iz = 0;
		if (str[i] == 'o' && iz == 0) {
			str[i] = 'a';
			iz = 1;
		}
		if (str[i] == 'a' && iz == 0) {
			str[i] = 'o';
			iz = 1;
		}
		i++;
	}
	std::cout << str;
	return str;
}
void fof(int& aa, int& bb) {
	int v = aa;
	aa = bb;
	bb = v;
}

int aver_mas(mas[10], const int size) {
	int min = mas[0];
	int max = mas[0];
	int i = 0;
	while (i < 10) {
		if (mas[i] < min) {
			min = mas[i];
		}
		if (mas[i] > max) {
			max = mas[i];
		}
		i++;
	}
	return (max + min) / 2;
}
int main() {

	int a;
	cin >> a;
	factorial(a);

	int a1, b;
	cin >> a1 >> b;
	average(a1, b);

	int a2;
	cin >> a2;
	f1(a2);

	double x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	distance(x1, x2, y1, y2);

	int a3;
	cin >> a3;
	one(a3);

	int a4;
	cin >> a4;
	if (prostoe(a4) == 1) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}

	int b2;
	cin >> b2;
	cout << e(b2);

	int a6, b3;
	cin >> a6 >> b3;
	cout << s(a6, b3);

	int a7;
	cin >> a7;
	cout << r(a7);

	int d, s;
	cin >> d >> s;
	cout << pow(d, s);

	string str;
	cin >> str;
	sr(str);

	int aa, bb;
	cin >> aa >> bb;
	fof(aa, bb);
	cout << aa << " " << bb;

	int mas[10];
	mas[0] = 11;
	mas[1] = 12;
	mas[2] = 13;
	mas[3] = 14;
	mas[4] = 15;
	mas[5] = 16;
	mas[6] = 17;
	mas[7] = 18;
	mas[8] = 19;
	mas[9] = 20;
	const int size = 10;
	aver_mas(mas);
	return 0;
}
Leave a Comment