-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInfinite_loop.cpp
More file actions
51 lines (47 loc) · 1016 Bytes
/
Infinite_loop.cpp
File metadata and controls
51 lines (47 loc) · 1016 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
#include "Infinite_loop_header.h"
DWORD WINAPI pi_dec(LPVOID lpParameter)
{
const int n = 999999999;
const int dim = ((10 * n) / 3);
int i, j, k, resto, digant, nueves, aux;
int pi[dim + 1];
for (i = 1; i <= dim; i++) pi[i] = 2;
nueves = 0; digant = 0;
for (i = 1; i <= n; i++)
{
resto = 0;
for (j = dim; j >= 1; j--)
{
aux = 10 * pi[j] + resto*j;
pi[j] = aux % (2 * j - 1);
resto = aux / (2 * j - 1);
}
pi[1] = resto % 10;
resto = resto / 10;
if (resto == 9) nueves++;
else if (resto == 10)
{
//for (k = 1; k <= nueves; k++) printf("0");
digant = 0;
nueves = 0;
}
else
{
digant = resto;
if (nueves != 0)
{
//for (k = 1; k <= nueves; k++) printf("9");
nueves = 0;
}
}
}
int a = Num_dec_before_thread;
HANDLE hThread;
if (i > a) {
hThread = CreateThread(NULL, NULL, pi_dec, NULL, NULL, NULL);
a = a + Num_dec_before_thread;
}
//printf("%i", digant);
//scanf("%i");
return NULL;
}