Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main () {
- int number1; // первое число в тройке - то есть 1 в последовательности [1, 2, 3]
- int number2; // второе число в тройке - то есть 2 в последовательности [1, 2, 3]
- int number3; // третье число в тройке - то есть 3 в последовательности [1, 2, 3]
- int threeCounter = 0;
- int quantity = 0;
- double max, average;
- srand(time(nullptr));
- do {
- number3 = rand() % 50;
- if (number3 != 0) {
- cout << number3 << endl;
- if (quantity % 3 == 0) {
- number1 = number3;
- }
- if (quantity % 3 == 1) {
- number2 = number3;
- }
- if (quantity >= 3) {
- max = number1;
- if (number2 > max) {
- max = number2;
- }
- if (number3 > max) {
- max = number3;
- }
- average = (number1 + number2 + number3 - max) / 2;
- if (sqrt(max) > average) {
- cout << "pair: " << number1 << ", " << number2 << ", " << number3 << endl;
- threeCounter++;
- }
- }
- quantity++;
- }
- } while (number3 != 0);
- cout << "All: " << threeCounter;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement