-
Notifications
You must be signed in to change notification settings - Fork 0
/
Zadacha2.cpp
37 lines (32 loc) · 988 Bytes
/
Zadacha2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <Windows.h>
#include <conio.h>
#include <stdio.h>
#include <math.h>
using namespace std;
int main()
{
system("chcp 1251 >nul");
int n;
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
while (true)
{
int el = 1, //Ïåðøå ÷èñëî
num = 0; //Íîìåð åëåìåíòà
double sum = 0; //Ïî÷àòêîâà ñóìà ÷èñë
while (sum <= 5) //Ïîêè ñóìà ÷èñë íå á³ëüøå 5
{
cout << pow(2, (1. / el)) << " - "<< el<<"-é åëåìåíò"<< endl; //Âèâåäåííÿ ÷èñëà
sum += pow(2, (1. / el)); //ϳäðàõóíîê ñóìè ÷èñë
el++; //Çíàõîäæåííÿ íàñòóïíîãî ÷èñëà(íà 1 á³ëüøå)
num++; //Çá³ëüøèòè ë³÷èëüíèê ÷èñåë íà 1
}
cout << endl;
cout << "Âñüîãî " << num << " åëåìåíò³â. \n¯õíÿ ñóìà äîð³âíþº " << sum << endl;
cout << "n/N - exit" << endl;
n = _getch();
if (n == 78 || n == 110 || n == 210 || n == 242) exit(0);
system("cls");
}
}