Ejemplo n.º 1
0
void input()
{
	printf( "n> " );
	string line;
	getline( cin, line );

	size_t comma = line.find( "," );
	cout << endl;

	chrono::time_point<chrono::steady_clock> start;
	chrono::time_point<chrono::steady_clock> end;

	if (comma == string::npos )	// single mode
	{
		int n = atoi( line.c_str() );
		if ( n < 0 ) return;

		start = chrono::high_resolution_clock::now();
		Integer f = fibonacci( n );
		end = chrono::high_resolution_clock::now();

		f.print( Fibonacci::getNumberPrefix( n ) );
		f.toFile( FILENAME );
	}
	else	// range mode
	{
		i64 b = atoll( line.substr( 0, comma ).c_str() );
		i64 e = atoll( line.substr( comma+1, line.length() ).c_str() );

		start = chrono::high_resolution_clock::now();
		fibonacci_range( b, e );
		end = chrono::high_resolution_clock::now();
	}

	if ( benchmark )
	{
		chrono::duration<i64, nano> time = end - start;
		printf( "mode: %s | time: %lli ms", mode.c_str(), time.count()/ 1000000);
	}
	cout << endl;
	input();
}