资源描述:
《西工大c语言poj作业》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、T081、阶乘合计#includeintfun(intn){inti,m=1,sum=0;for(i=1;i<12;i++){m*=i;sum+=m;if(n==m)return1;if(m>n)break;}if(sum-mintmain(){charfx[5];intn,i,
2、d,j;scanf("%s%d",fx,&n)!=EOF;{switch(fx[0]){case'S':d=0;break;case'E':d=1;break;case'N':d=2;break;case'W':d=3;break;}for(i=0;i=0?d:d+4){case0:printf("South");break;case1:printf("East");break;case2:printf("North");break;case3:p
3、rintf("West");break;}}return0;}T083、三点顺序#includeintmain(){intx1,y1,x2,y2,x3,y3;scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3);{if((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1)>0)printf("0");//逆时针elseprintf("1");//顺时针}return0;}T084、TheRatioofgainerstolosers#include#includei
4、ntmain(){inta,b,p,q,p1,q1;scanf("%d%d",&a,&b);p=1,q=0;for(q1=1;q1<=b;q1++){p1=(double)(q1*a)/(double)b+0.5;if(q*fabs(a*q1-b*p1)#include#includeintmain(){chars[5001
5、],s1[5000];intpri[5000],max=0,len,i,j,x,y,m=0;gets(s);len=strlen(s);for(i=0;i=0&&i+jmax){max=2*j+1;x=pri[i-j];y=pri[i+j];}}for(j=
6、0;i-j>=0&&i+jmax){max=2*j+2;x=pri[i-j];y=pri[i+j+1];}}}for(i=x;i<=y;i++)printf("%c",s[i]);printf("");return0;}T086、Easyproblem#include#include#includeintmain(){intk;longlongi,N;{k=0;scanf("%I64d",&N);for(i=1;(i+1)*(
7、i+1)<=N+1;i++){if((N+1)%(i+1)==0){k++;}}printf("%d",k);}return0;}T087、Hailstone#include#definemax(a,b)a>b?a:b#definemin(a,b)a>b?b:aintmain(){inta,b,m,n,max,count,k;scanf("%d%d",&a,&b);m=max(a,b);n=min(a,b);max=0;for(;n<=m;n++){k=n;count=1;while(k!=1