Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ############################################
- ЧЕТНЫЕ ЧИСЛА ИЗ МАССИВА
- #include <iostream>
- using namespace std;
- void Input(int arr[], int size) {
- for (int i = 0; i < size; i++) {
- cout << "arr[" << i << "] = ";
- cin >> arr[i];
- }
- }
- void Output(int mass[], int size, int arr[]){
- for (int i = 0; i < size; i++) {
- if (arr[i] % 2 == 0) {
- mass[i] = arr[i];
- cout << mass[i] << " ";
- }
- }
- cout << "}" << endl;
- }
- int main()
- {
- setlocale(LC_ALL, "RUSSIAN");
- int *arr;
- int *mass;
- int size;
- cout << "Введите размер массива." << endl;
- cout << "n= ";
- cin >> size;
- if (size <= 0) {
- cout << "Размер массива должен быть положительным" << endl;
- return 1;
- }
- arr = new int[size];
- int n = 0;
- Input(arr, size);
- for (int i = 0; i < size; i++) {
- if (arr[i] % 2 == 0) {
- n++;
- }
- }
- cout << " " << endl;
- cout << "Массив с четными числами: { ";
- mass = new int[n];
- Output(mass, size, arr);
- cout << " " << endl;
- return 0;
- }
- ##########################################
- МАСКИМАЛЬНЫЙ ЧЛЕН МАССИВА
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "RUSSIAN");
- int *arr;
- int size;
- cout << "Введите размер массива." << endl;
- cout << "n= ";
- cin >> size;
- if (size <= 0) {
- cerr << "Размер массива должен быть положительным" << endl;
- return 1;
- }
- arr = new int[size];
- for (int i = 0; i < size; i++) {
- cout << "arr[" << i << "] = ";
- cin >> arr[i];
- }
- int max = arr[0];
- for (int i = 1; i < size; i++) {
- if (arr[i] > max) {
- max = arr[i];
- }
- }
- cout << " " << endl;
- cout << "Максимальный элемент массива: " << max << endl;
- cout << " " << endl;
- delete[] arr;
- return 0;
- }
- ###############
- 3 числа
- #include <iostream>
- using namespace std;
- double Max(double x, double y){
- if (x > y){
- return x;
- }
- else return y;
- }
- double Min(double x, double y){
- if (x < y){
- return x;
- }
- else return y;
- }
- int main()
- {
- setlocale(LC_ALL, "RUSSIAN");
- int A, B, C, max, min;
- cout << "Vvedite 1 chislo" << endl;
- cin >> A;
- cout << "Vvedite 2 chislo" << endl;
- cin >> B;
- cout << "Vvedite 3 chislo" << endl;
- cin >> C;
- max = Max(A, Max(B, C));
- min = Min(C, Min(A, B));
- cout << "MAX = " << max << endl;
- cout << "MIN = " << min << endl;
- return 0;
- }
- #######################
- #include <iostream>
- using namespace std;
- double distance(double a, double b, double c, double d){
- return sqrt(pow((c - a), 2) + pow((d - b), 2));
- }
- int main()
- {
- setlocale(LC_ALL, "RUSSIAN");
- double x1, y1, x2, y2, x3, y3, P, p, S;
- cout << "Please enter A (x1,y1) = " << endl;
- cin >> x1;
- cin >> y1;
- cout << "Please enter B (x2,y2) = " << endl;
- cin >> x2;
- cin >> y2;
- cout << "Please enter C (x3,y3) = " << endl;
- cin >> x3;
- cin >> y3;
- P = distance(x1, y1, x2, y2) + distance(x2, y2, x3, y3) + distance(x1, y1, x3, y3);
- p = P / 2;
- S = sqrt(p*(p - distance(x1, y1, x2, y2))*(p - distance(x2, y2, x3, y3))*(p - distance(x1, y1, x3, y3)));
- cout << " "<< endl;
- cout << p << endl;
- cout << S << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement