📄 ansi_c++.cpp
字号:
// HugeCalcDemo.cpp : Defines the entry point for the console application.
//
// Project -> Setting -> C/C++ -> Code Generation --> Use run-time library:
// Win32 Debug: Debug Multithreaded DLL
// Win32 Release: Multithreaded DLL
#include <iostream.h>
#include "../../../HugeCalc_API/CppAPI/Include/HugeCalc.h" // 公共接口
#include "../../../HugeCalc_API/CppAPI/Include/HugeInt.h" // 10进制系统
#include "../../../HugeCalc_API/CppAPI/Include/HugeIntX.h" // 16进制系统
#pragma message( "automatic link to ../../../HugeCalc_API/CppAPI/Lib/HugeCalc.lib" )
#pragma comment( lib, "../../../HugeCalc_API/CppAPI/Lib/HugeCalc.lib" )
// http://www.swox.com/gmp/#TRY
// 1 + gcd(87324,78263148,7896) * (10^1989879887 mod 471!)
#if 1
#define _Test_HI
#define integer CHugeInt
#else
#define _Test_HX
#define integer CHugeIntX
#endif
int main(int argc, char* argv[])
{
// printf("Hello World!\n");
cout << "Call " << HugeCalc::GetVer() << endl << endl;
if ( HC_LICENSE_NONE == HugeCalc::GetLicenseLevel())
{
cout << endl << "警告:您未通过 HugeCalc.dll 的许可认证!" \
<< endl << endl << "解决方案可选下列方案之一:" \
<< endl << " 一、请移动到文件夹“../CopyrightByGuoXianqiang[/..]/” 下;" \
<< endl << " 二、或请在 HugeCalc.chm 中进行注册(一劳永逸)。" \
<< endl;
return (-1);
}
CONST UINT32 u32Num[] = { 87324, 78263148, 7896 };
CONST UINT32_CVECTOR vU32Num = { &(u32Num[0]), sizeof( u32Num ) / sizeof( u32Num[0] ) };
integer hugeResult;
// 初始化
HugeCalc::EnableTimer( TRUE );
HugeCalc::ResetTimer();
hugeResult.PowMod( 10, 1989879887, integer().Factorial( 471 ));
hugeResult *= HugeCalc::Gcd( vU32Num );
++hugeResult;
// 记录计算耗时
CONST UINT32 u32Timer_Calc = HugeCalc::GetTimer( TIMER_UNIT_ms );
HugeCalc::ResetTimer();
CONST LPCTSTR lpShow = hugeResult.GetStr( FS_DEFAULT );
CONST UINT32 u32Timer_Output = HugeCalc::GetTimer( TIMER_UNIT_us );
// 输出
cout << endl << "The result of executing 1 + gcd(87324,78263148,7896) * (10^1989879887 mod 471!) is:" \
<< endl << endl << lpShow << " (" << hugeResult.GetDigits() << " digits)" \
<< endl << endl << "computation took " << u32Timer_Calc << " ms" \
<< endl << "output conversion took " << u32Timer_Output << " us" \
<< endl << endl;
cout << endl << "下面将生成前 100 个百位素数(十进制下)。。。" << endl << endl;
system( "pause" );
cout << endl;
CHugeInt hugePrime((UINT32) 1 );
hugePrime.DecLShift( 99 ); // = 10^99
HugeCalc::EnableTimer( TRUE );
HugeCalc::ResetTimer();
for ( UINT32 i=0; i<100; ++i )
{
cout << endl << (LPCTSTR)hugePrime.NextPrime( hugePrime );
}
HugeCalc::EnableTimer( FALSE );
cout << endl << "耗时为:" << HugeCalc::GetTimerStr( FT_DOT06SEC_s ) << endl << endl;
system( "pause" );
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -