标题: 数学计算工具 i 的重构版new i [打印本页]
作者: happy886rr 时间: 2017-2-23 20:56 标题: 数学计算工具 i 的重构版new i
NEW I.EXE 版本1.0
摘要:
=============================================================================
数学计算工具I.EXE的重构版,更换了新的内核和计算核心,改用自主研发的静逆波兰
解析器,多处if改用case实现,抛弃低端的strcmp函数, 重写了程序主体架构,完善
了之前不安全的代码。采用双引擎素数筛法,可以快捷获取一万亿以内的素数。
new i 工具的用法与旧 i 已经不同,旧版本宣布作废,今后将只对new i 做升级维护。
=============================================================================
下载链接: https://pan.baidu.com/s/1tPFRm3Mck7XYBXWME2pD4w?pwd=9w8g
用法:(开关支持近似输入法,比如 i /get-permutation 可以直接输入成 i /get-pe )
-----------------------------------------------------------------------------
i [options] {arguments}...
-----------------------------------------------------------------------------
/help Show help information
/get-fib [n]
/get-fact [n]
/get-pi [Accuracy]
/get-e [Accuracy]
/get-combination [m] [n]
/get-permutation [m] [n]
/get-datedifference [start_day] [end_day]
/get-hash [string]
/get-result [expression]
/get-statistics [arrays]
/get-solution [coefficients]
/get-elements
/get-mytax [principal] [interest rate] [number of compound interest]
/get-interest [annuity] [interest rate] [interest rate period]
/get-annuity [income] [three insurance a gold]
/pri-list [m] [n]
/pri-count [max]
/pri-index [m] [n]
/pri-check [prime]
/pri-sum [max]
-----------------------------------------------------------------------------
示例:
-----------------------------------------------------------------------------
REM 计算字符串哈希值
i /get-hash "i"
Crc32 : e66c3671
Md5 : 865c0c0b4ab0e063e5caa3387c1a8741
Sha1 : 042dc4512fa3d391c5170cf3aa61e6a638f84342
Sha256: de7d1b721a1e0632b7cf04edf5032c8ecffa9f9a08492152b926f1a5a7e765d7
-----------------------------------------------------------------------------
REM 计算组合数 C(33,6)
i /get-comb 33 6
=1107568
-----------------------------------------------------------------------------
REM 计算排列数 P(33,6)
i /get-perm 33 3
=32736
-----------------------------------------------------------------------------
REM 科学计算 5*(arctan(cos(sin(ln(lg(2.71828))))))
i /get-result 5*(arctan(cos(sin(ln(lg(2.71828))))))
=3.178987410777
-----------------------------------------------------------------------------
REM 素数切片
i /pri-list 100000000 100000500
┌────────────────────────┐
100000007 100000037 100000039 100000049 100000073
100000081 100000123 100000127 100000193 100000213
100000217 100000223 100000231 100000237 100000259
100000267 100000279 100000357 100000379 100000393
100000399 100000421 100000429 100000463 100000469
100000471 100000493
└────────────────────────┘
-----------------------------------------------------------------------------
REM 第一千万个素数
i /pri-index 10000000
=179424673
-----------------------------------------------------------------------------
REM 素性检测
i /pri-check 100000357
100000357 是素数
-----------------------------------------------------------------------------
REM 计算30亿内的素数和
i /pri-sum 3000000000
=211169315361937456
-----------------------------------------------------------------------------
REM 统计300亿内的素数个数
i /pri-count 30000000000
在30000000000以内共有1300005926个素数
-----------------------------------------------------------------------------
RME 解高次方程
i /get-solu 3 0 5 -6 -9
一元四次方程3x^4+0x^3+5x^2-6x-9=0的解为:
┌────────────────────────┐
共轭复根:-0.252438186547+1.696390660707i
-0.252438186547-1.696390660707i
实数解为: 1.293411063722
-0.788534690627
└────────────────────────┘
-----------------------------------------------------------------------------
RME 计算日期差
i /get-dat 19951207 20170223
=7749
-----------------------------------------------------------------------------
REM 其他功能请自行体验,不再详叙。
-----------------------------------------------------------------------------
备注:
-----------------------------------------------------------------------------
常数类
pi 3.1415926535897932
e 2.7182818284590452
通用类
rand 随机数
round 四舍五入
int 取整
ceil 向上舍入
floor 向下舍入
abs 绝对值
sqrt 开方
lg 常用对数,以10为底
ln 自然对数
exp e的次幂
gamma 伽玛函数
torad 度转弧度
+ 加
- 减
* 乘
/ 除
% 取余数
^ 次方
! 阶乘
三角函数类
sin、cos、tan
arcsin、arccos、arctan
双曲函数类
sinh、cosh、tanh
arcsinh、arccosh、arctanh
-----------------------------------------------------------------------------
英译:
-----------------------------------------------------------------------------
CONSOLE CALCULATE TOOL, COPYRIGHT@2017~2019 BY HAPPY, VERSION 1.0
-----------------------------------------------------------------------------
i [options] {arguments}...
-----------------------------------------------------------------------------
/help Show help information
/get-fib [n]
/get-fact [n]
/get-pi [Accuracy]
/get-e [Accuracy]
/get-combination [m] [n]
/get-permutation [m] [n]
/get-datedifference [start_day] [end_day]
/get-hash [string]
/get-result [expression]
/get-statistics [arrays]
/get-solution [coefficients]
/get-elements
/get-mytax [principal] [interest rate] [number of compound interest]
/get-interest [annuity] [interest rate] [interest rate period]
/get-annuity [income] [three insurance a gold]
/pri-list [m] [n]
/pri-count [max]
/pri-index [m] [n]
/pri-check [prime]
/pri-sum [max]
-----------------------------------------------------------------------------
2017-02-23
核心源码:- /*
- CONSOLE CALCULATE TOOL, COPYRIGHT@2017~2019 BY HAPPY, VERSION 1.0
- THE NEW I.EXE
- LIN: EQUATION.LIB HASH.LIB REVPOLISH.LIB SMALLFUN.LIB PRIME.LIB
- */
-
- #include <math.h>
- #include <stdio.h>
- #include <stdbool.h>
- #include <stdlib.h>
- #include <string.h>
-
- //定义帮助说明//////////////////////////////////////////////////////
- #define HELP_INFORMATION "\
- CONSOLE CACLUTE TOOL, COPYRIGHT@2017~2018 BY HAPPY, VERSION 1.0 \n\
- -----------------------------------------------------------------\n\
- i [option] {parameters}\n\
- -----------------------------------------------------------------\n\
- /get-fib [n]\n\
- /get-fact [n]\n\
- /get-pi [Accuracy]\n\
- /get-e [Accuracy]\n\
- /get-combination [m] [n]\n\
- /get-permutation [m] [n]\n\
- /get-datedifference [start_day] [end_day]\n\
- /get-hash [string]\n\
- /get-result [expression]\n\
- /get-statistics [arrays]\n\
- /get-solution [coefficients]\n\
- /get-elements\n\
- /get-mytax [principal] [interest rate] [number of compound interest]\n\
- /get-interest [annuity] [interest rate] [interest rate period]\n\
- /get-annuity [income] [three insurance a gold]\n\
- \n\
- /pri-list [m] [n]\n\
- /pri-count [max]\n\
- /pri-index [m] [n]\n\
- /pri-check [prime]\n\
- /pri-sum [max]\n\
- -----------------------------------------------------------------\n\
- 02-23-2017\n"
- ////////////////////////////////////////////////////////////////////
- #define CHEMICAL_ELEMENTS "------Chemical_elements------\n\
- ⅠA 0 \n\
- ┌──┐ ┌──┐\n\
- │1 H│ │2 He│\n\
- 1│ 氢 │ │ 氦 │\n\
- │1.01│ ⅡA ⅢA ⅣA ⅤA ⅥA ⅦA│4.00│\n\
- ├──┼──┐ ┌──┬──┬──┬──┬──┼──┤\n\
- │3 Li│4 Be│ │5 B│6 C│7 N│8 O│9 F│10Ne│\n\
- 2│ 锂 │ 铍 │ │ 硼 │ 碳 │ 氮 │ 氧 │ 氟 │ 氖 │\n\
- │6.94│9.01│ │10.8│12.0│14.0│16.0│19.0│20.2│\n\
- ├──┼──┤ ├──┼──┼──┼──┼──┼──┤\n\
- │11Li│12Be│ │13Al│14Si│15 P│16 S│17Cl│18Ar│\n\
- 3│ 钠 │ 镁 │ │ 铝 │ 硅 │ 磷 │ 硫 │ 氯 │ 氩 │\n\
- │23.0│24.3│ ⅢB ⅣB ⅤB ⅥB ⅦB Ⅷ ⅠB ⅡB │27.0│28.1│31.0│32.1│35.5│40.0│\n\
- ├──┼──┼──┬──┬──┬──┬──┬──┬──┬──┬──┬──┼──┼──┼──┼──┼──┼──┤\n\
- │19 K│20Ca│21Sc│22Ti│23 V│24Cr│25Mn│26Fe│27Co│28Ni│29Cu│30Zn│31Ga│32Ge│33As│34Se│35Br│36Kr│\n\
- 4│ 钾 │ 钙 │ 钪 │ 钛 │ 钒 │ 铬 │ 锰 │ 铁 │ 钴 │ 镍 │ 铜 │ 锌 │ 镓 │ 锗 │ 砷 │ 硒 │ 溴 │ 氪 │\n\
- │39.1│40.1│45.0│47.8│51.0│52.0│54.9│55.9│58.9│58.7│63.6│65.4│69.8│72.6│74.9│79.0│79.9│83.8│\n\
- ├──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤\n\
- │37Rb│38Sr│39 Y│40Zr│41Nb│42Mo│43Tc│44Ru│45Rh│46Pd│47Ag│48Cd│49In│50Sn│51Sb│52Te│53 I│54Xe│\n\
- 5│ 铷 │ 锶 │ 钇 │ 锆 │ 铌 │ 钼 │ 锝 │ 钌 │ 铑 │ 钯 │ 银 │ 镉 │ 铟 │ 锡 │ 锑 │ 碲 │ 碘 │ 氙 │\n\
- │85.5│87.6│88.9│91.2│92.9│95.9│[99]│101.│103.│106.│108.│112.│115.│119.│122.│128.│127.│131.│\n\
- ├──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤\n\
- │55Cs│56Ba│57- │72Hf│73Ta│74 W│75Re│76Os│77Ir│78Pt│79Au│80Hg│81Tl│82Pb│83Bi│84Po│85At│86Rn│\n\
- 6│ 铯 │ 钡 │ 71│ 铪 │ 钽 │ 钨 │ 铼 │ 锇 │ 铱 │ 铂 │ 金 │ 汞 │ 铊 │ 铅 │ 铋 │ 钋 │ 砹 │ 氡 │\n\
- │133.│137.│镧系│179.│181.│184.│186.│190.│192.│195.│197.│201.│204.│207.│209.│209*│210*│222*│\n\
- ├──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤\n\
- │87Fr│88Ra│89- │104Rf 105Db 106Sg 107Bh 108Hs 109Mt 110Ds 111Rg 112Cn 113 │114 │115 │116 │117 │118 │\n\
- 7│ 钫 │ 镭 │ 103│钅卢│钅杜│钅喜│钅波│钅黑│钅麦│钅达│钅仑│ 鎶 │ Uut│ Fl │ Uup│ Lv │ Uus│ Uuo│\n\
- │223*│226.│锕系│265*│268*│271*│270*│277*│276*│281*│280*│285*│284*│289*│289*│283*│294*│294*│\n\
- └──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘\n\
- \n\
- ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐\n\
- 镧│57La│58Ce│59Pr│60Nd│61Pm│62Sm│63Eu│64Gd│65Tb│66Dy│67Ho│68Er│69Tm│70Yb│71Lu│\n\
- 系│ 镧 │ 铈 │ 镨 │ 钕 │ 钷 │ 钐 │ 铕 │ 钆 │ 铽 │ 镝 │ 钬 │ 铒 │ 铥 │ 镱 │ 镥 │\n\
- │139.│140.│141.│144.│147*│150.│152.│157.│159.│163.│165.│167.│169.│173.│175.│\n\
- ├──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤\n\
- 锕│89Ac│90Th│91Pa│92 U│93Np│94Pu│95Am│96Cm│97Bk│98Cf│99Es│100Fm 101Md 102No 103Lr \n\
- 系│ 锕 │ 钍 │ 镤 │ 铀 │ 镎 │ 钚 │ 镅 │ 锔 │ 锫 │ 锎 │ 锿 │ 镄 │ 钔 │ 锘 │ 铹 │\n\
- │227.│232.│231.│238.│237.│244*│243*│247*│247*│251*│252*│257*│258*│259*│260*│\n\
- └──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘\n"
- ////////////////////////////////////////////////////////////////////
- #define SUPER_PRIMES " The larger number of prime numbers is as follows:\n\
- ┌─────────┬──────────────────┐\n\
- │ range N │ Number of prime numbers PI(N) │\n\
- ├─────────┼──────────────────┤\n\
- │ 10**1 │ 4 │\n\
- │ 10**2 │ 25 │\n\
- │ 10**3 │ 168 │\n\
- │ 10**4 │ 1,229 │\n\
- │ 10**5 │ 9,592 │\n\
- │ 10**6 │ 78,498 │\n\
- │ 10**7 │ 664,579 │\n\
- │ 10**8 │ 5,761,455 │\n\
- │ 10**9 │ 50,847,534 │\n\
- │ 10**10 │ 455,052,511 │\n\
- │ 10**11 │ 4,118,054,813 │\n\
- │ 10**12 │ 37,607,912,018 │\n\
- │ 10**13 │ 346,065,536,839 │\n\
- │ 10**14 │ 3,204,941,750,802 │\n\
- │ 10**15 │ 29,844,570,422,669 │\n\
- │ 10**16 │ 279,238,341,033,925 │\n\
- │ 10**17 │ 2,623,557,157,654,233 │\n\
- │ 10**18 │ 24,739,954,287,740,860 │\n\
- │ 10**19 │ 234,057,667,276,344,607 │\n\
- │ 10**20 │ 2,220,819,602,560,918,840 │\n\
- │ 10**21 │ 21,127,269,486,018,731,928 │\n\
- │ 10**22 │ 201,467,286,689,315,906,290 │\n\
- │ 10**23 │ 1,925,320,391,606,803,968,923 │\n\
- │ 10**24 │ 18,435,599,767,349,200,867,866 │\n\
- │ 10**25 │ 176,846,309,399,143,769,411,680 │\n\
- │ 10**26 │ 1,699,246,750,872,437,141,327,603 │\n\
- └─────────┴──────────────────┘"
- ////////////////////////////////////////////////////////////////////
-
- /***************定义全局变量*************/
- //定义开关词目
- #define SENSITIVE_NUM 20
- typedef enum{ GET_FIB , GET_FACT , GET_PI , GET_E , GET_COMBINATION , GET_PERMUTATION , GET_DATEDIFFERENCE , GET_HASH , GET_RESULT , GET_STATISTICS , GET_SOLUTION , GET_ELEMENTS , GET_MYTAX , GET_INTEREST , GET_ANNUITY , PRI_LIST , PRI_COUNT , PRI_INDEX , PRI_CHECK , PRI_SUM }senum;
- static const char* SENSITIVE_WORDS[]={"/GET-FIB", "/GET-FACT", "/GET-PI", "/GET-E", "/GET-COMBINATION", "/GET-PERMUTATION", "/GET-DATEDIFFERENCE", "/GET-HASH", "/GET-RESULT", "/GET-STATISTICS", "/GET-SOLUTION", "/GET-ELEMENTS", "/GET-MYTAX", "/GET-INTEREST", "/GET-ANNUITY", "/PRI-LIST", "/PRI-COUNT", "/PRI-INDEX", "/PRI-CHECK", "/PRI-SUM"};
- static const char SENSITIVE_ARGVS[]={ 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 0, 2, 3, 3, 1, 1, 1, 1, 1};
-
- /***************库函数声明***************/
- //字符串哈希
- void GetStringHash(const char*);
- //解高次方程
- void Univariate_Equation(int, char**);
- //逆波兰核心
- double RevPolishCore(const char*);
- //阶乘函数
- void SmallFact(int);
- //π函数
- int SmallPI(int, long long, long long, long long, long long);
- //e函数
- void SmallE(int);
- //个税计算
- double SmallTax(int, int);
- //计算日期差
- void SmallDateminus(int, int);
-
- /***************功能函数群***************/
- //辨关键词
- int itifyWORDS(const char* strARGV)
- {
- int SN;
- for(SN=0; SN<SENSITIVE_NUM; SN++){
- char *op=(char*)strARGV, *kp=(char*)SENSITIVE_WORDS[SN];
- while(*kp!='\0'){
- if( (('a'<= *op && *op<='z')?*op-32:*op) != (('a'<= *kp && *kp<='z')?*kp-32:*kp) ){break;}
- op++;kp++;
- }
- if(
- ((*kp=='\0') && (*op==' '||*op=='\t'||*op=='\r'||*op=='\n'||*op=='\0')) ||
- (int)kp-(int)SENSITIVE_WORDS[SN] >6
- ){
- return SN;
- }
- }
- return -1;
- }
- //计算组合数C(n,m)
- long long Combination(long long n,long long m)
- {
- if(m==1){
- return n;
- }
- else{
- if(m>n/2){m=n-m;}
- long long sum=1, *r=(long long*)calloc(1000, sizeof(long long)), i, j, count=1;
- for(j=n;j>n-m;j--){
- sum*=j,i=1;
- for(i=2;i<=m;i++){
- if(r[i]==0 && sum%i==0){
- sum/=i, r[i]=1, count+=1;
- }
- }
- }
- if(count==m && sum>0){free(r);return sum;}
- }
- return -1;
- }
- //计算排列数P(n,m)
- long long Permutation(long long n,long long m)
- {
- long long sum=1, i, j;
- for(i=1,j=n; i<=m; i++,j--){
- sum*=j;
- if(sum<0){
- return -1;
- break;
- }
-
- }
- return sum;
- }
- //斐波那契函数
- void Fibonacci(int n, int k)
- {
- int i,j,tmp=0,add;
- int *Fa=(int*)calloc(110000, sizeof(int)), *Fb=(int*)calloc(110000, sizeof(int));
-
- Fa[1]=Fb[1]=1;
- if(n==0 &&k==0){
- printf("fib(0) = 0");
- }else if(n<=2 &&k==0){
- printf("fib(%d) = 1",n);
- }else{
- int N=ceil(n*log10((1+sqrt(5))/2)-log10(5)/2);
- for(i=3;i<=n;i++){
- add=0;
- for(j=1;j<=N/9+1;j++){
- tmp=Fa[j]+Fb[j]+add, Fa[j]=Fb[j], add=tmp/1000000000, Fb[j]=tmp%1000000000;
- }
- }
- if(n<45){
- printf("fib(%d) = %d", n, Fb[1]);
- }else if(n>=45){
- printf("fib(%d) = %d", n, Fb[N/9+1]);
- for(j=N/9;j>1;j--){
- printf("%09d",Fb[j]);
- }
- printf("%09d",Fb[1]);
- }
- }
- free(Fa);
- free(Fb);
- }
- //统计函数
- void Statistics(int sargc, char** sargv)
- {
- double s=0,q=0;
- int i;
- for(i=2;i<sargc;i++){
- s+=atof(sargv[i]);
- }
- double e=s/(sargc-2);
- for(i=2;i<sargc;i++){
- q+=(atof(sargv[i])-e)*(atof(sargv[i])-e);
- }
- fprintf(stdout,
- "[Statistics]\n"
- " Sample expectation E(x)=%16.12lf\n"
- " Sample variance D(x)=%16.12lf\n"
- " Free deviation Q(x)=%16.12lf\n"
- " Standard deviation V(x)=%16.12lf\n"
- " And values S(x)=%16.12lf\n"
- ,
- e, q/(sargc-2), sqrt(q/(sargc-3)), sqrt(q/(sargc-2)), s
- );
- }
-
-
-
- /*************MAIN主函数入口*************/
- int main(int argc, char** argv)
- {
- //参数过少则抛出使用说明
- if( argc==1 || (argc>1 && argv[1][0]=='/' && (argv[1][1]=='?'||argv[1][1]=='h'||argv[1][1]=='H')) ){
- fputs(HELP_INFORMATION, stdout);
- exit(0);
- }
-
- //解析开关命令
- //setlocale(LC_ALL, "chs");
- int SN=itifyWORDS(argv[1]);
-
- if(!(0<=SN &&SN<=19)){
- //无法识别的开关
- fprintf(stderr, "Unrecognized switch '%s'\n", argv[1]);
- exit(1);
- }
-
- if(argc< 1+1+SENSITIVE_ARGVS[SN]){
- //缺少必要参数
- fprintf(stderr, "The switch '%s' needs %d parameters\n", argv[1], SENSITIVE_ARGVS[SN]);
- exit(1);
- }
-
- //执行开关命令
- switch((senum)SN)
- {
- //GET系列开关
- case GET_FIB:
- Fibonacci(atoi(argv[2]), 0);
- break;
- case GET_FACT:
- SmallFact(atoi(argv[2]));
- break;
- case GET_PI:
- {
- int n=((int)(atoll(argv[2])/4+1)*4)*3.5;
- if(n>126000){
- printf("超出设定计算范围");
- }else{
- SmallPI(n,0,0,0,0);
- }
- }
- break;
- case GET_E:
- SmallE(atoi(argv[2]));
- break;
- case GET_COMBINATION:
- fprintf(stdout, "%lld\n", Combination(atoll(argv[2]), atoll(argv[3])) );
- break;
- case GET_PERMUTATION:
- fprintf(stdout, "%lld\n", Permutation(atoll(argv[2]), atoll(argv[3])) );
- break;
- case GET_DATEDIFFERENCE:
- SmallDateminus(atoi(argv[2]), atoi(argv[3]));
- break;
- case GET_HASH:
- GetStringHash((const char*)argv[2]);
- break;
- case GET_RESULT:
- fprintf(stdout, "%.12lf\n", RevPolishCore(argv[2]));
- break;
- case GET_STATISTICS:
- Statistics(argc, argv);
- break;
- case GET_SOLUTION:
- Univariate_Equation(argc, argv);
- break;
- case GET_ELEMENTS:
- system("mode con cols=120 lines=30");
- fputs(CHEMICAL_ELEMENTS, stdout);
- break;
- case GET_MYTAX:
- SmallTax(atoi(argv[2]), atoi(argv[3]));
- break;
- case GET_INTEREST:
- fprintf(stdout, "%.12lf\n", atof(argv[2])*pow(atof(argv[3])+1.0,atof(argv[4])) );
- break;
- case GET_ANNUITY:
- fprintf(stdout, "%.12lf\n", atof(argv[2])*(pow(atof(argv[3])+1,atoi(argv[4]))-1)/atof(argv[3]));
- break;
-
- //素数系列开关
- case PRI_LIST:
- if(argc==3){
- long long n =atoll(argv[2]);
- if(n<500){
- preprime(n);
- }else if(n<=30000000){
- prime((int)(n));
- }else if(n<999900000000){
- class_prime(1000000);
- prif(n);
- }else{
- fputs(SUPER_PRIMES, stdout);
- }
- }else if(argc==4){
- long long N =atoll(argv[3]);
- if(N<=30000000){
- listprimes(atoll(argv[2]),atoll(argv[3]));
- }else if(N<999900000000){
- class_prime(1000000);
- long long M=atoll(argv[2]);
- M=M-(M&1),N=N+(N&1);
- if(N-M<=10000000 && N-M>0){
- int i, t=FFJ(M, N), T=0, LP;
- bool* bm=get_boolp();
- printf("%s 到 %s 的素数切片,共计%d个素数\n", argv[2], argv[3], t);
- printf("┌────────────────────────────────┐\n");
- for(i=1; i<=10000000; i+=2){
- if(!bm[i]){
- T++;
- printf("%13lld", i+M);
- if(T%5==0){printf("\n");}
- if(T==t){LP=i;break;}
- }
- }
- printf( "\n└────────────────────────────────┘"
- "\n该范围内最大的素数为:%lld"
- ,M+LP
- );
- }
-
- }else{
- printf("超出切片范围");
- }
- }
- break;
- case PRI_COUNT:
- {
- long long n=atoll(argv[2]);
- if(n<=50000000000){
- countprimes(n);
- }else{
- fputs(SUPER_PRIMES, stdout);
- }
- }
- break;
- case PRI_INDEX:
- if(argc==3){
- indexprime(atoll(argv[2]));
-
- }else{
- index2prime(atoll(argv[2]),atoll(argv[3]));
- }
- break;
- case PRI_CHECK:
- if(isPrime(atoll(argv[2]),5)){
- fprintf(stdout, "%s是素数", argv[2]);
- }
- else{
- fprintf(stdout, "%s不是素数",argv[2]);
- }
- break;
- case PRI_SUM:
- {
- long long n =atoll(argv[2]);
- if(n<=4200000000){
- fprintf(stdout, "%lld", primesum(n));
- }
- }
- break;
- }
-
- return 0;
- }
复制代码
作者: codegay 时间: 2017-2-24 09:49
i new i new new i
作者: happy886rr 时间: 2017-2-24 10:17
回复 2# codegay
,不错,就叫这个名字吧。inew
作者: niudd 时间: 2017-2-28 11:38
很牛X的代码,学习了
作者: niudd 时间: 2017-2-28 11:38
很牛X的代码,学习了
作者: 老刘1号 时间: 2017-4-19 22:46
突然看到了周期表……吃鲸……
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |