F
FSMehmet
Hi how are you???
Hey who can help me to find the 111 digit of pi number in C++
Pleaseeee helpppppppppp.
Hey who can help me to find the 111 digit of pi number in C++
Pleaseeee helpppppppppp.
Hi how are you???
Hey who can help me to find the 111 digit of pi number in C++
Pleaseeee helpppppppppp.
FSMehmet said:Hi how are you???
Hey who can help me to find the 111 digit of pi number in C++
Pleaseeee helpppppppppp.
FSMehmet said:Hey who can help me to find the 111 digit of pi number in C++
Hi how are you???
Hey who can help me to find the 111 digit of pi number in C++
Pleaseeee helpppppppppp.
There are some nice hits on google if you give it
pi algorithm
as a search target. But since C++ does not deal innately with numbers as
large as 111 digits, you will need some way to attack that problem.
Start with 3.14159 and work from thereFSMehmet said:Hi how are you???
Hey who can help me to find the 111 digit of pi number in C++
Pleaseeee helpppppppppp.
FSMehmet said:Hey who can help me to find the 111 digit of pi number in C++
FSMehmet said:Hey who can help me to find the 111 digit ofpinumber in C++
#include <iostream>
#include <ostream>
int main(){ unsigned long i, j, k, n, p,
q, x, m = 111, len = 370,pi[ 371 ];
for( x = len; x > 0; --x )pi[ x ]= 2;
::std::cout << "3."; n = 0; p = 0;
for( j = 0; j <= m; ++j )
{ q = 0; for( i = len; i > 0; --i )
{ x = 10 *pi[ i ]+ q * i;
pi[ i ]= x %( 2 * i - 1 );
q = x /( 2 * i - 1 ); }
pi[ 1 ]= q % 10; q = q / 10; if( q == 9 )++n;
else if( q == 10 ) { putchar( '1' + p );
for( ; n; --n )::std::cout << '0'; p = 0; }
else { if( j > 1 )::std::cout << p;
for( ; n; --n )::std::cout << '9'; p = q; }}
::std::cout << p << '\n'; }
FSMehmet said:Hey who can help me to find the 111 digit of pi number in C++
#include <iostream>
#include <ostream>
int main(){ unsigned long i, j, k, n, p,
q, x, m = 111, len = 370, pi[ 371 ];
for( x = len; x > 0; --x )pi[ x ]= 2;
::std::cout << "3."; n = 0; p = 0;
for( j = 0; j <= m; ++j )
{ q = 0; for( i = len; i > 0; --i )
{ x = 10 * pi[ i ]+ q * i;
pi[ i ]= x %( 2 * i - 1 );
q = x /( 2 * i - 1 ); }
pi[ 1 ]= q % 10; q = q / 10; if( q == 9 )++n;
else if( q == 10 ) { putchar( '1' + p );
for( ; n; --n )::std::cout << '0'; p = 0; }
else { if( j > 1 )::std::cout << p;
for( ; n; --n )::std::cout << '9'; p = q; }}
::std::cout << p << '\n'; }
#include <iostream>
#include <ostream>int main(){ unsigned long i, j, k, n, p,
q, x, m = 111, len = 370, pi[ 371 ];
for( x = len; x > 0; --x )pi[ x ]= 2;
::std::cout << "3."; n = 0; p = 0;
for( j = 0; j <= m; ++j )
{ q = 0; for( i = len; i > 0; --i )
{ x = 10 * pi[ i ]+ q * i;
pi[ i ]= x %( 2 * i - 1 );
q = x /( 2 * i - 1 ); }
pi[ 1 ]= q % 10; q = q / 10; if( q == 9 )++n;
else if( q == 10 ) { putchar( '1' + p );
for( ; n; --n )::std::cout << '0'; p = 0; }
else { if( j > 1 )::std::cout << p;
for( ; n; --n )::std::cout << '9'; p = q; }}
::std::cout << p << '\n'; }
Readability fail.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.