-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaytay.cpp
More file actions
58 lines (47 loc) · 793 Bytes
/
Copy pathtaytay.cpp
File metadata and controls
58 lines (47 loc) · 793 Bytes
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <chrono>
#include <thread>
#include <atomic>
std::atomic<bool> detenedor(false);
void esperador(){
std::cin.get();
detenedor =true;
}
int fac(int b){
int k =b;
int f =1;
for(int i =1; i<b; i++){
f*=k;
k--;
if(k==1)
break;
}
return f;
}
double taytayE(int a ){
double totalitaris =1;
for(double i =1.0;
i<a;
i+=1.0){
totalitaris+= 1.0/fac(i);
}
return totalitaris;
}
void warten(){
std::cout << ".";
std::cout.flush();
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
int main(){
int k =0;
std::cout<<"accuracy? ";
std::cin>>k;
std::cout<<taytayE(k);
std::cin.ignore();
std::thread imputado(esperador);
while(!detenedor){
warten();
}
imputado.join();
return 0;
}