您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 质量控制/管理 > 西工大POJ100题(全新)
1·计算A+B2·圆及圆球等的相关计算3·计算成绩4·找最大数5·找幸运数6·奖金发放7·出租车费8·是该年的第几天9·成绩转换10·求建筑高度11·区间内素数12·计算π13·两个整数之间所有的素数14·最次方数15·自然数立方的乐趣16·五猴分桃17·完全数18·二分求根19·你会存钱吗?20·级数和21·幸运数字722·粒子裂变23·特殊整数24·最大乘积25·解不等式26·危险的组合27·子序列的和29·探索合数世纪30·韩信点兵31·亲和数32·高低交换33·循环移位35·组合数36·积分计算37·数据加密38·获取指定二进制位39·ACKERMAN40·不会吧,又是A+B41·平均值函数42·插入排序43·一维数组赋值44·右下角45·右上角46·山迪的麻烦47·冒泡排序48·恐怖水母49·左上角50·一维数组加法51·字符串排序52·字符串左中右53·文章统计54·找出数字55·字符串比较56·THECLOCK57·合并字符串58·特殊要求的字符串59·字符串逆序60·COINTEST61·小型数据库62·单词频次65·检测位图长宽67·子字符串替换68·复数69·字符串加密编码70·重组字符串71·大数除法72·创建与遍历职工链表73·大数加法74·大数减法75·链表节点删除76·链表动态增长或缩小77·大数乘法78·精确乘幂80·火车站81·操场训练82·HAILSTONE84·阶乘合计85·王的对抗86·三点顺序87·公园喷水器88·勇闯天涯89·不屈的小蜗90·THERATIOOFGAINERSTOLOSERS91·GRAVEYARD92·ARITHMETICPROGRESSIONS93·SCORING94·HOUSEBOAT97·BEE98·CHECKSUMALGORITHM99·Hanoi2100·Specializednumber1·计算A+B#includestdio.hintmain(){inta,b,sum;scanf(%d%d,&a,&b);sum=a+b;printf(%d,sum);}2·圆及圆球等的相关计算#includestdio.hintmain(){floatr,h,l,s,sq,vq,vz,pi=3.141592653;scanf(%f%f,&r,&h);l=2*pi*r;s=pi*r*r;sq=4*pi*r*r;vq=4.0/3*pi*r*r*r;vz=pi*r*r*h;printf(%.2f\n%.2f\n%.2f\n%.2f\n%.2f\n,l,s,sq,vq,vz);return0;}3·计算成绩#includestdio.hintmain(){floata,b,c,sum,ave;scanf(%f%f%f,&a,&b,&c);sum=a+b+c;ave=sum/3.0;printf(%.6f\n%.6f,sum,ave);return0;}4·找最大数#includestdio.hintmain(){inta,b,c,t;scanf(%d%d%d,&a,&b,&c);if(ab)t=a,a=b;if(ac)t=a,a=c;printf(%d,a);return0;}5·找幸运数#includestdio.hintmain(){inti,j,a;scanf(%d,&a);i=0;j=a;while(j){i=10*i+(j%10);j=j/10;}if(i==a)printf(yes\n);elseprintf(no\n);return0;}6·奖金发放#includestdio.hintmain(){floatl;scanf(%f,&l);if(l=10)l=l*0.1;elseif(l=20)l=10*0.1+(l-10)*0.075;elseif(l=40)l=10*0.1+10*0.075+(l-20)*0.05;elseif(l=60)l=10*0.1+10*0.075+20*0.05+(l-40)*0.03;elseif(l=100)l=10*0.1+10*0.075+20*0.05+20*0.03+(l-60)*0.015;elsel=10*0.1+10*0.075+20*0.05+20*0.03+40*0.015+(l-100)*0.01;printf(%.6f,l);return0;}7·出租车费#includestdio.h#includemath.hintmain(){floata,n,t;scanf(%f,&a);if(a=2)n=7;elseif(a=15){t=a-floor(a);if(t==0)n=7+(floor(a)-2)*1.5;elsen=7+(floor(a)-1)*1.5;}else{t=a-floor(a);if(t==0)n=7+13*1.5+(floor(a)-15)*2.1;elsen=7+13*1.5+(floor(a)-14)*2.1;}printf(%.6f,n);return0;}8·是该年的第几天#includestdio.hintmain(){inty,m,d,n,a;scanf(%d-%d-%d,&y,&m,&d);if((y%4==0&&y%100!=0)||(y%400==0))a=29;elsea=28;switch(m){case1:n=d;break;case2:n=31+d;break;case3:n=31+a+d;break;case4:n=62+a+d;break;case5:n=92+a+d;break;case6:n=123+a+d;break;case7:n=153+a+d;break;case8:n=184+a+d;break;case9:n=215+a+d;break;case10:n=245+a+d;break;case11:n=276+a+d;break;case12:n=306+a+d;break;}printf(%d,n);return0;}9·成绩转换#includestdio.hintmain(){intn;scanf(%d,&n);if(n60)printf(E\n);elseif(n70)printf(D\n);elseif(n80)printf(C\n);elseif(n90)printf(B\n);elseprintf(A\n);return0;}10·求建筑高度#includestdio.hintmain(){floatx,y,a,b,c,d;scanf(%f,%f,&x,&y);a=(x-2)*(x-2)+(y-2)*(y-2);b=(x-2)*(x-2)+(y+2)*(y+2);c=(x+2)*(x+2)+(y-2)*(y-2);d=(x+2)*(x+2)+(y+2)*(y+2);if(a=1||b=1||c=1||d=1)printf(10);elseprintf(0);return0;}11·区间内素数#includestdio.h#includemath.hintmain(){inti,n=500,cnt=0,sum=0;while(n=800){for(i=2;i=n-1;i++)if(n%i==0)break;if(i==n)cnt=cnt+1,sum=sum+pow((-1),cnt)*n;n=n+1;}printf(%d%d,cnt,sum);return0;}12·计算π#includestdio.h#includemath.hintmain(){ints=1;doublepi=0,n=1,t=1;while(fabs(t)1e-6)pi=pi+t,n=n+2,s=-s,t=s/n;pi=pi*4;printf(%.6f,pi);return0;}13·两个整数之间所有的素数#includestdio.hintmain(){inta,b,t,i;scanf(%d%d,&a,&b);if(ab)t=a,a=b,b=t;while(a=b){for(i=2;i=a-1;i++)if(a%i==0)break;if(i==a)printf(%d,a);a++;}return0;}14·最次方数#includestdio.hintmain(){intx,a,m=1,n=1;scanf(%d%d,&x,&a);while(m=a){n=n*x;n=n%1000;m=m+1;}printf(%d,n);return0;}15·自然数立方的乐趣#includestdio.hintmain(){intn,a,i,t;scanf(%d,&n);a=n*(n-1)+1;t=n*n*n;printf(%d*%d*%d=%d=,n,n,n,t);for(i=1;in;i++){printf(%d+,a);a=a+2;}printf(%d,a);return0;}16·五猴分桃#includestdio.hintdivides(intn,intm){if(n/5==0||n%5!=1)return0;if(m==1)return1;returndivides(n-n/5-1,m-1);}intmain(){intn,a;for(n=1;;n++)if(divides(n,5)){printf(%d,n);break;}a=(((((n-1)*4/5-1)*4/5-1)*4/5-1)*4/5-1)*4/5;printf(%d,a);return0;}17·完全数#includestdio.hintmain(){inti,n,sum=0;for(n=2;n1000;n++){sum=0;for(i=1;i=n/2;i++){if(n%i==0)sum=sum+i;}if(sum==n){printf(%d=,n);for(i=1;in/2;i++)if(n%i==0)printf(%d+,i);i=n/2;printf(%d\n,i);}}return0;}18·二分求根#includemath.h#includestdio.hdoublefun(doublex){return2*x*x*x-4*x*x+3*x-6;}doubleroot(doublea,doubleb,doublee){doublex1,x2,y1,x,y;x1=a;x2=b;do{x=(x1+x2)/2;y=fun(x);y1=fun(x1);if((y0&&y10)||(y0&&y10))x1=x;elsex2=x;/*endif*/}while(fabs(y)e);returnx;}intmain(void){doublem,n;scanf(%f%f,&m,&n);doublex=root(m,n,1e-8);printf(%.2f\n,x);return0;}19·你会存钱吗?#includestdio.h#includemath.hintmain(){inti8,i5,i3,i2,i1,n8,n5,n3,n2,n1;floatmax=0,term;for(i8=0;i83;i8++)/*穷举所有可能的存款方式*/for(i5=0;i5=(20-8*i8)/5;i5++)for(i3=0;i3=(20-8*i8-5*i5)/3;i3++)for(i2=0;i2=(20-8*i8-5*i5-3*i3)/2;i2++){i1=20-8*i8-5*i5-3*i3-2*i2;term=2000.0*pow((double)(1+0.0063*12),(double)i1)*pow((double)(1+2*0.0063*12),(double)i2)*pow((double)(1+3*0.0069*12),(double)i3)*pow((double)(1+5*0.0075*12),(double)i5)*pow
本文标题:西工大POJ100题(全新)
链接地址:https://www.777doc.com/doc-5324218 .html