西工大noj问题详解完整版
西工大C语言POJ习题答案讲解
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a<b)
a=b;
if(a<c)
a=c;
printf("%d\n",a);
return 0;
}
5.
#include<stdio.h>
int main()
{
int i=0,j=0,k=1;
char a[6];
e=29;
else
e=28;
switch (b)
{
case 1:n=c;break;
case 2:n=g+c;break;
case 3:n=g+e+c;break;
case 4:n=g+e+g+c;break;
case 5:n=g+e+g+f+c;break;
case 6:n=g+e+g+f+g+c;break;
b=(a-2)*1.5+7;
else b=7;
}
printf("%lf\n",b);
return 0;
}
8.
#include <stdio.h>
int main()
{
int a,b,c,e,f=30,g=31,n;
scanf("%d-%d-%d",&a,&b,&c);
if((a%400==0)||(a%100!=0&&a%4==0))
return 0;
西北工业大学机械原理课后答案第4章
第四章 平面机构的力分析题4-7机械效益Δ是衡量机构力放大程度的一个重要指标,其定义为在不考虑摩擦的条件下机构的输出力(力矩)与输入力(力矩)之比值,即Δ=d r d r F F M M //=。
试求图示各机构在图示位置时的机械效益。
图a 所示为一铆钉机,图b 为一小型压力机,图c 为一剪刀。
计算所需各尺寸从图中量取。
(a ) (b) (c)解:(a)作铆钉机的机构运动简图及受力 见下图(a )由构件3的力平衡条件有:02343=++R R rF F F由构件1的力平衡条件有:04121=++d R R按上面两式作力的多边形见图(b )得θcot ==∆d r F F(b )作压力机的机构运动简图及受力图见(c )由滑块5的力平衡条件有:04565=++R R F F G由构件2的力平衡条件有:0123242=++R R R 其中 5442R R =按上面两式作力的多边形见图(d ),得tF G =∆(c) 对A 点取矩时有 b F a F d r ⋅=⋅ab =∆其中a 、b 为F r 、F d 两力距离A 点的力臂。
tF G =∆(d)(a)(b)drR41F R43F dG题4-8在图示的曲柄滑块机构中,设已知l AB=0.1m,l BC=0.33m,n1=1500r/min(为常数),活塞及其附件的重量G3=21N,连杆质量G2=25N,J S2=0.0425kg·m2,连杆质心S2至曲柄销B的距离l BS2=l BC/3。
试确定在图示位置时活塞的惯性力以及连杆的总惯性力。
解:1) 选定比例尺, mmml005.0=μ绘制机构运动简图。
(图(a) )2)运动分析:以比例尺vμ作速度多边形,如图(b)以比例尺aμ作加速度多边形如图4-1 (c)244.23smcpaaC=''=μ2222100smspaaS=''=μ22215150sBCcnlalaBCtBC=''==μμα3) 确定惯性力活塞3:)(37673333NagGamFCSI=-=-=方向与cp''相反。
西工大NOJ100题+解答
西工大NOJ100题+解答#includestdio.h int main() {int a,b,sum;scanf(“%d%d",a, sum=a+b;printf("%d\n",sum); return 0; }#includestdio.h #define PI 3.***-***** int main() {double r,h,l,s,sq,vq,vz; scanf("%lf%lf",r, l=2*PI*r; s=PI*r*r; sq=4*PI*r*r; vq=PI*r*r*r*4/3; vz=PI*r*r*h;printf("%.2lf\n%.2lf\n%.2lf\n%.2lf\n%.2lf\n",l,s,sq,vq,vz); return 0; }#includestdio.h int main() {double ma,eng,c,sum,ave;scanf("%lf%lf%lf",ma,eng, sum=ma+eng+c; ave=sum/3;printf("%lf\n%lf\n",sum,ave); return 0; }#includestdio.h int main() {int a,b,c,m;scanf("%d%d%d",a,b, if (ab) m=a; else m=b; if (mc) m=c; printf("%d",m); return 0; }#includestdio.h int main() {int n;scanf("%d",if ((1000n*****)(n/1000==n%10)(n/100%10==n/10%10)) printf("yes\n"); else if((100n=1000)(n/100==n%10)) printf("yes\n"); else if((10n=100)(n/10==n%10)) printf("yes\n"); else if(0n=10) printf("yes\n"); else printf("no\n"); return 0; }#includestdio.h int main() {double l,bon; scanf("%lf", if(l=10) bon=l*0.1;else if(l20) bon=1+(l-10)*0.075; else if(l40) bon=1.75+(l-20)*0.05; else if(l60) bon=2.75+(l-40)*0.03; else if(l100) bon=3.35+(l-60)*0.015; else bon=3.95+(l-100)*0.01; printf("%lf\n",bon); return 0; }#includestdio.h int main() {double d,m; scanf("%lf", if(d=2) m=7; else if(d=15){if(d-2==(int)(d-2)) m=7+(d-2)*1.5; else m=7+((int)(d-2)+1)*1.5; }else if(d-15==(int)(d-15)) m=26.5+(d-15)*2.1; else m=26.5+((int)(d-15)+1)*2.1; printf("%lf\n",m); return 0; } #includestdio.h int main() {int y,m,d,Days,sum;scanf("%d-%d-%d",y,m,if((y%4==0y%100!=0)||(y%400==0)) Days=29; else Days=28;switch(m){case 1:sum=d;break; case 2:sum=31+d;break;case 3:sum=31+Days+d;break; case 4:sum=62+Days+d;break; case 5:sum=92+Days+d;break; case 6:sum=123+Days+d;break; case 7:sum=153+Days+d;break; case 8:sum=184+Days+d;break; case 9:sum=215+Days+d;break; case 10:sum=245+Days+d;break; case 11:sum=276+Days+d;break; case 12:sum=307+Days+d;break; }printf("%d\n",sum); return 0; }#includestdio.h int main() {int i;scanf("%d",if(i=90) printf("A\n");else if(i=80) printf("B\n"); else if(i=70) printf("C\n"); else if(i=60) printf("D\n"); else printf("E\n"); return 0; }#includestdio.h int main() {double x,y;scanf("%lf,%lf",x,if((x-2)*(x-2)+(y-2)*(y-2)=1) printf("10");else if((x-2)*(x-2)+(y+2)*(y+2)=1) printf("10"); else if((x+2)*(x+2)+(y-2)*(y-2)=1) printf("10"); elseif((x+2)*(x+2)+(y+2)*(y+2)=1) printf("10"); else printf("0"); return 0; }#includestdio.h int main() {double l,x,r;scanf("%lf %lf",l,while((2*l*l*l-4*l*l+3*l-6)!=0(2*r*r*r-4*r*r+3*r-6)!=0){ x=(l+r)/2;if((2*l*l*l-4*l*l+3*l-6)*(2*x*x*x-4*x*x+3*x-6)=0) r=x; else l=x; }if(2*l*l*l-4*l*l+3*l-6==0) printf("%.2lf",l); else printf("%.2lf",r); return 0; }#includestdio.h #includemath.h int main() {int i=800,t=2,cnt=0,sum=0; double e=-1; while(i=500){ while(t=i-1){if(i%t==0) break; t++; }if(t==i) e=pow(-1,cnt),sum=sum+e*i,cnt++; i--; t=2; }printf("%d %d",cnt,sum); return 0; }#includestdio.h #includemath.h int main() {int a=1;double b=1,pi=0,c=1; while(fabs(c)=1e-6)pi=pi+c,b=b+2,a=-a,c=a/b; pi=pi*4;printf("%lf\n",pi); return 0; }#includestdio.h int main() {int a1=1,a2=1,n=2,sum=2,t; while(sum=100){ t=a1; a1=a2; a2=t+2*a2; sum=sum+a2; n++; }printf("%d\n",n-1); while(sum=1000){ t=a1; a1=a2;a2=t+2*a2; sum=sum+a2; n++; }printf("%d\n",n-1); while(sum=*****){ t=a1; a1=a2;a2=t+2*a2;sum=sum+a2; n++; }printf("%d\n",n-1); }#includestdio.h int main() {int x,a,s,n=1;scanf("%d %d",x, s=x; if(a!=0){for(;nn++) {s=s*x;if(s=1000) s=s/100%10*100+s/10%10*10+s%10; } }printf("%d\n",s); return 0; }#includestdio.h int main() {int m,n,s;scanf("%d", s=n*n*n;printf("%d*%d*%d=%d=",n,n,n,s); for(m=1;s!=n*m;m++);if(n%2==1){for(s=-n/2;ss++)printf("%d+",m+2*s); printf("%d",m+n/2*2); } else{for(s=-n/2;sn/2-1;s++)printf("%d+",m+s*2+1);printf("%d",m+(n/2-1)*2+1); }return 0; }#includestdio.h int main() {char a,b,c,x,y,z;a='A',b='B',c='C',x='X',y='Y',z='Z'; printf("%c=%c\n",a,z); printf("%c=%c\n",b,x); printf("%c=%c\n",c,y); return 0; }#includestdio.h int main() {int a,b,t;scanf("%d %d",a, if(ab)t=a,a=b,b=t; for(;aa++){for(t=2;tt++)if(a%t==0) break; if(t==a)printf("%d ",a); }return 0; }#includestdio.h int main() {int n=1;double a1=1,a2=2,a3,sum=2; while(n=19){ a3=a1+a2;sum=sum+a3/a2; a1=a2; a2=a3; n++; }printf("%lf\n",sum); return 0; }#includestdio.h #includemath.h int main() {double a; int n=0;scanf("%lf", a=fabs(a);if(a=1)printf("0\n"); else{while(a1){ a=a/10; n++; }printf("%d\n",n); }return 0; }#includestdio.h int main() {int a=1,b=0,t,m,n=0; scanf("%d", while(nt){ m=b; b=3*a+2*b; a=m; n++; }printf("%d %d",a,b); return 0; }。
noj大作业
程序设计挑战式课程设计极限挑战挑战,不是为着征服自然,而是为着突破自我,超越自我生命有极限,思想无极限,高度有极限,境界无极限作业名称:算法演示程序 学 院:航海学院 班 级:03011403 学 号:2013300951 姓 名:苏和 团队组成:西北工业大学2022年4月25日1、问题与背景(描述程序所要解决的问题或应用背景)2、开发工具(列出所使用的开发工具和第3方开发库)3、主要功能(详细说明程序的功能)4、设计内容(详细描述解决问题的原理和方法、算法、数据结构等)5、程序文件与工程名称(标出程序中所有文件名、工程名称及其说明)6、函数模块(程序中各个函数的原型声明及其说明)7、使用说明(运行程序的小型说明书)8、程序开发总结(简要叙述编写本作业的收获与思考)进行了巩固和训练。
9、运行截图(附上程序运行的截图画面,至少有1幅,截图越翔实得分越高)Windows中抓取当前活动窗口:Alt + Print Screen,抓取全屏:Print Screen。
或者使用HyperSnap等软件(百度搜索)。
10、源程序(附上程序源代码,若是多个文件,标出文件名)1.sort.cpp#include <stdio.h>#include <stdlib.h>#include "myh.h"int main(){int a[100],n,i,k;while(1){printf("\n\t\t\t 欢迎使用排序算法演示程序\n\n\n");printf(" 请输入所要排序的数据个数N(N<100)=");scanf("%d",&n);printf("\n");printf(" 请输入所要排序的数据:");printf("\n\n\t");for(i=0;i<n;i++) scanf("%d",&a[i]);//输入数据printf("\n");printf(" 请选择一种排序方法:\n\n");printf("\t1.冒泡排序\t 2.选择排序\t 3.插入排序\n");printf("\t4.快速排序\t 5.堆排序\t 6.归并排序\t 7.基数排序\n\n"); printf(" 您的选择是:");scanf("%d",&k);switch(k){case 1: Bubble(a,n);break;case 2: Selection(a,n);break;case 3: Insertion(a,n);break;case 4: Quick(a,n,0,n-1);break;case 5: Heap(a,n);break;case 6: MergeSort(a,0,n-1);break;case 7: int *a_p = a;Bucket(a_p,n);break;}printf("\n");printf(" 请选择排列方式:1.从小到大 2.从大到小\n\n");printf(" 您的选择是:");scanf("%d",&k);printf("\n\n");printf(" 结果是:\n\t");if(k=1){for(i=0;i<n;i++) printf("%d ",a[i]);//正序输出}else{for(i=n-1;i>=0;i--) printf("%d ",a[i]);//倒序输出}printf("\n\n 按Q键并确认退出,其他任意键继续:");getchar();if(getchar()=='q') break;printf("\n\n\n");}return 0;}2.sort_fun.cpp#include "myh.h"#include <math.h>#include <stdlib.h>void Bubble(int a[],int n){//冒泡排序int i,j,t;for(j=0;j<n-1;j++)for(i=0;i<n-1-j;i++)//一趟排序if(a[i]>a[i+1]){t=a[i];a[i]=a[i+1];a[i+1]=t;//交换}}void Selection(int a[],int n){//选择排序int i,j,k,t;for(i=0;i<n-1;i++){k=i;for(j=i+1;j<n;j++)if(a[j]<a[k])k=j;//找出最小数if(i!=k){t=a[i];a[i]=a[k];a[k]=t;//如果不是本身则与相应的a[i]交换}}}void Insertion(int a[],int n){//插入排序int i,k,t;for(i=1;i<n;i++){t=a[i];k=i-1;while(t<a[k]){//与前边的数依次比较a[k+1]=a[k];//逐个后移k--;if(k==-1)break;}a[k+1]=t;//插入原数据}}void Quick(int a[],int n,int left,int right){//快速排序,left、right分别为数组左右边界int i,j,t;if(left<right){i=left;j=right+1;while(1){while(i+1<n&&a[++i]<a[left]);//向后搜索大于a[left]的数while(j-1>-1&&a[--j]>a[left]);//向前搜索小于a[left]的数if(i>=j)break;t=a[i];a[i]=a[j];a[j]=t;//交换}t=a[left];a[left]=a[j];a[j]=t;Quick(a,n,left,j-1);Quick(a,n,j+1,right);//左右半部分分别再次快速排序}}void Shift(int a[] , int i , int m){//建堆int k,t;t=a[i];k=2*i+1;while(k<m){if((k<m-1)&&(a[k]<a[k+1])) k ++;if(t<a[k]){a[i]=a[k];//使数列成为一棵完全二叉树的存储结构i=k; //即成为小根堆k=2*i+1; //ki<=k(2i)且ki<=k(2i+1)(1≤i≤n)}else break;}a[i]=t;}void Heap(int a[] , int n){//堆排序int i,k;for(i=n/2-1;i>=0;i--) Shift(a,i,n);//初始化操作:将a[n]构造为初始堆for(i=n-1;i>=1;i--){//每一趟排序的基本操作:将当前无序区的k=a[0]; //堆顶记录a[1]和该区间的最后一个记录交换,a[0]=a[i]; //然后将新的无序区调整为堆(亦称重建堆)a[i]=k;Shift(a,0,i);}}void MergeSort(int R[],int low,int high){//归并排序int mid;if(low<high){mid=(low+high)/2;MergeSort(R,low,mid);MergeSort(R,mid+1,high);Merge(R,low,mid,high);//重复运行}}void Merge(int *R,int low,int m,int high){int i=low,j=m+1,p=0;int *R1;R1=(int *)malloc((high-low+1)*sizeof(int));//申请空间,用以放置合并后的序列if(!R1)return;while(i<=m&&j<=high)R1[p++]=(R[i]<=R[j])?R[i++]:R[j++];while(i<=m)R1[p++]=R[i++];while(j<=high)R1[p++]=R[j++];for(p=0,i=low;i<=high;p++,i++) R[i]=R1[p];//两两比较选择相对小的元素放入到合并空间}void Bucket(int *p , int n){//基数排序int maxNum= findMaxNum( p , n );//获取数组中的最大数int loopTimes = getLoopTimes(maxNum);//获取最大数的位数,次数也是再分配的次数。
理论力学_西北工业大学中国大学mooc课后章节答案期末考试题库2023年
理论力学_西北工业大学中国大学mooc课后章节答案期末考试题库2023年1.SQL Server提供了3种数据库还原模型,它们是()。
答案:简单还原、完整还原、大容量日志还原2.已知两个关系:职工(职工号,职工名,性别,职务,工资)设备(设备号,职工号,设备名,数量)其中“职工号”和“设备号”分别为职工关系和设备关系的关键字,则两个关系的属性中,存在一个外部关键字为()。
答案:设备关系的“职工号”3.学生成绩表grade中有字段score,float类型,现在要把所有在55至60分之间的分数提高5分,以下SQL语句正确的是()。
答案:UPDATE grade SET score=score+5 WHERE score BETWEEN 55 AND 604.在为students数据库的student_info表录入数据时,常常需要一遍又一遍地输入“男”到学生“性别”列,以下()方法可以解决这个问题。
答案:创建一个DEFAULT约束(或默认值)5.设A、B两个数据表的记录数分别为3和5,对两个表执行交叉联接查询,查询结果中最多可获得()条记录。
答案:156.为了从数据源向数据集填充数据,应该调用()。
答案:DataAdapter.Fill方法7.在如下2个数据库的表中,若雇员信息表EMP的主键是雇员号,部门信息表DEPT的主键是部门号,部门号为EMP表的外键。
若执行所列出的操作,()操作要求能执行成功。
答案:从雇员信息表EMP中删除行('010','王宏达','01','1200')在雇员信息表EMP中插入行('102','赵敏','01','1500')将雇员信息表EMP中雇员号='010'的工资改为1600元8.假设有关系R和S,在下列的关系运算中,()运算要求:“R和S具有相同的元数,且它们的对应属性的数据类型也相同”。
西工大C语言POJ习题答案之欧阳德创编
一.1.第一季10题全(注:第五题问题已经解决,确认AC!)#include <stdio.h>int main(){int a,b,sum;scanf("%d%d",&a,&b);sum=a+b;printf("%d\n",sum);return 0;}2.#include <stdio.h>#define PI 3.1415926int main(){double r,h,l,s,sq,vq,vz;scanf("%lf%lf",&r,&h);l=2*PI*r;s=PI*r*r;sq=4*PI*r*r;vq=4*PI*r*r*r/3;vz=s*h;printf("%.2lf\n%.2lf\n%.2lf\n%.2lf\n%.2lf\n",l,s,sq, vq,vz); return 0;}3.#include <stdio.h>int main(){int a,b,c;double d,e;scanf("%d%d%d",&a,&b,&c); d=a+b+c;e=d/3;printf("%lf\n%lf\n",d,e);return 0;}4.#include <stdio.h>int main(){int a,b,c;scanf("%d%d%d",&a,&b,&c); if(a<b)a=b;if(a<c)a=c;printf("%d\n",a);return 0;}5.#include<stdio.h>int main(){int i=0,j=0,k=1;char a[6];while((a[i]=getchar())!='\n') { i++;}for(;i>0;i--){if(a[j]==a[i-1]){j++;continue;}else {k=0;break;}}if(k==1)printf("yes\n");elseprintf("no\n");}6.#include<stdio.h>int main(){double a,c;scanf("%lf",&a);switch((int)a/10){case 0:c=a*0.1;break;case 1:c=(a-10)*0.075+10*0.1;break;case 2:case 3:c=(a-20)*0.05+10*0.075+10*0.1;break; case 4: case 5:c=(a-40)*0.03+20*0.05+10*0.075+10*0.1;break;case 6:case 7:case 8:case 9:c=(a-60)*0.015+20*0.03+20*0.05+10*0.075+10*0.1;break; default:c=(a-100)*0.01+40*0.015+20*0.03+20*0.05+10*0.075+10 *0.1;}printf("%lf\n",c);return 0;}7.#include<stdio.h>int main(){double a,b,c;scanf("%lf",&a);c=(int)a;if(a>c)a=c+1;if(a>15)b=(a-15)*2.1+7+13*1.5;else {if(a>2)b=(a-2)*1.5+7;else b=7; }printf("%lf\n",b);return 0;}8.#include <stdio.h>int main(){int a,b,c,e,f=30,g=31,n;scanf("%d-%d-%d",&a,&b,&c);if((a%400==0)||(a%100!=0&&a%4==0))e=29;elsee=28;switch (b){case 1:n=c;break;case 2:n=g+c;break;case 3:n=g+e+c;break; case 4:n=g+e+g+c;bre ak;case 5:n=g+e+g+f+c;break;case 6:n=g+e+g+f+g+c;break;case 7:n=g+e+g+f+g+f+c;break;case 8:n=g+e+g+f+g+f+g+c;break;case 9:n=g+e+g+f+g+f+g+g+c;break;case 10:n=g+e+g+f+g+f+g+g+f+c;break;case 11:n=g+e+g+f+g+f+g+g+f+g+c;break;default: n=g+e+g+f+g+f+g+g+f+g+f+c;}printf("%d\n",n);return 0;}9.#include <stdio.h> int main(){int x;scanf("%d",&x);if(x>=90&&x<=100) printf("A\n");else if (x>=80)printf("B\n");else if (x>=70)printf("C\n");else if (x>=60)printf("D\n");elseprintf("E\n");return 0;}10.#include<stdio.h>int main(){double x,y,s;scanf("%lf,%lf",&x,&y);s=(x+2)*(x+2)+(y-2)*(y-2);if(s>1){s=(x+2)*(x+2)+(y+2)*(y+2);if(s>1){ s=(x-2)*(x-2)+(y+2)*(y+2); if(s>1){s=(x-2)*(x-2)+(y-2)*(y-2);if(s>1){printf("0\n");return 1;}}}}printf("10\n");return 0;}二。
西工大noj标准答案版.doc
西北工业大学 POJ答案绝对是史上最全版(不止100哦⋯⋯按首字母排序)1.“ 1“的传奇2.A+B3.A+BⅡ4.AB5.ACKERMAN6.Arithmetic Progressions7.Bee8.Checksum algorithm9.Coin Test10.Dexter need help11.Double12.Easy problem13.Favorite number14.Graveyard15.Hailstone16.HanoiⅡ17.Houseboat18.Music Composer19.Redistribute wealth20.Road trip21.Scoring22.Specialized Numbers23.Sticks24.Sum of Consecutive25.Symmetric Sort26.The Clock27.The Ratio of gainers to losers28.VOL 大学乒乓球比赛29.毕业设计论文打印30.边沿与内芯的差31.不会吧,又是 A+B32.不屈的小蜗33.操场训练34.插入链表节点35.插入排序36.插入字符37.成绩表计算38.成绩转换39.出租车费40.除法41.创建与遍历职工链表42.大数乘法43.大数除法44.大数加法45.单词频次46.迭代求根47.多项式的猜想48.二分查找49.二分求根50.发工资的日子51.方差52.分离单词53.分数拆分54.分数化小数55.分数加减法56.复数57.高低交换58.公园喷水器59.韩信点兵60.行程编码压缩算法61.合并字符串62.猴子分桃63.火车站64.获取指定二进制位65.积分计算66.级数和67.计算 A+B68.计算 PI69.计算π70.计算成绩71.计算完全数72.检测位图长宽73.检查图像文件格式74.奖金发放75.阶乘合计76.解不等式77.精确幂乘78.恐怖水母79.快速排序80.粒子裂变81.链表动态增长或缩短82.链表节点删除83.两个整数之间所有的素数84.路痴85.冒泡排序86.你会存钱吗87.逆序整数88.排列89.排列分析90.平均值函数91.奇特的分数数列92.求建筑高度93.区间内素数94.三点顺序95.山迪的麻烦96.删除字符97.是该年的第几天98.是该年的第几天99.数据加密100.搜索字符101.所有素数102.探索合数世纪103.特殊要求的字符串104.特殊整数105.完全数106.王的对抗107.危险的组合108.文件比较109.文章统计110.五猴分桃111.小型数据库112.幸运儿113.幸运数字” 7“114.选择排序115.寻找规律116.循环移位117.延伸的卡片118.羊羊聚会119.一维数组”赋值“120.一维数组”加法“121.勇闯天涯122.右上角123.右下角124.圆及圆球等的相关计算125.圆及圆球等相关计算126.程序员添加行号127.找出数字128.找幸运数129.找最大数130.整数位数131.重组字符串132.子序列的和133.子字符串替换134.自然数立方的乐趣135.字符串比较136.字符串复制137.字符串加密编码138.字符串逆序139.字符串排序140.字符串替换141.字符串左中右142.组合数143.最次方数144.最大乘积145.最大整数146.最小整数147.最长回文子串148.左上角149.左下角1.“ 1“的传奇#include <>#include <>#include <>int main(){int n,i,j,k=0,x=1,y,z,m,p,q,a,s=0;scanf("%d",&n);m=n;for(i=1;i<12;i++){m=m/10;k++;if(m==0)break;}q=n;k=k-1;for(a=1;a<=k;a++){x=x*10;}y=q%x;z=q/x;p=q-y;if(z>=2)s=s+x+z*k*(x/10); elses=s+z*k*(x/10); for(j=p;j<=n;j++) {m=j;for(i=1;i<12;i++){x=m%10;if(x==1)s++;m=m/10;if(m==0)break;}}printf("%d",s);return 0;}2.A+B#include <>int doubi(int n,int m) {n=n+m;n=n%100;return n;}int main(){int t,i,a[100],n,m; scanf("%d",&t);for (i=0;i<=(t-1);i++){scanf("%d%d",&n,&m);a[i]=doubi(n,m);}for (i=0;i<=(t-1);i++)printf("%d\n",a[i]); return 0;}3.A+BⅡ#include <>int main(){int A,B,sum;scanf("%d%d",&A,&B);sum=A+B;printf("%d\n",sum);return 0;}4.AB#include <>#include <>#include <>int main(){char s[100],q[100];double a,b,c;int n=0,i;scanf("%lf%lf",&a,&b);c=a*b;sprintf(s,"%.0lf",c);for(i=0;i<strlen(s);i++){n=n+s[i]-48;}while(n>=10){sprintf(q,"%d",n);n=0;for(i=0;i<strlen(q);i++)n=n+q[i]-48;}printf("%d",n);return 0;}5.ACKERMAN#include <>#include <>int ack(int x,int y){int n;if (x==0) {n=y+1;return n;}else if (y==0) n=ack(x-1,1);else n=ack(x-1,ack(x,y-1));return n;}int main(){int m,b;scanf("%d%d",&m,&b);m=ack(m,b);printf("%d",m);return 0;}6.Arithmetic Progressions #include <>#include <>int g(int n){int i;if(n==1) return 0;if(n==2) return 1;if(n==3) return 1;for(i=2;i<=sqrt(n);i++) if(n%i==0) return 0;return 1;}int f(int a,int b,int c){int i=0,s=a-b;if(c==1&&g(a)==1) return a;if(b==0&&g(a)!=1) return -1;while(1){s=s+b;if(g(s)) i++;if(i>=c) break;}return s;int main(){int a,b,c,d[100],i=0,n;while(1){scanf("%d%d%d",&a,&b,&c);if(a==0&&b==0&&c==0) break;d[i]=f(a,b,c);i++;}n=i;for(i=0;i<n;i++)printf("%d\n",d[i]);return 0;}7.Bee#include <>#include <>int main()int A[100],i=0,j,k,female=0,male=1,x;for(;;i++){scanf("%d",&A[i]);if(A[i]==-1)break;}for(j=0;j<i;j++){female=0,male=1;for(k=1;k<A[j];k++){x=female;female=male;male=x+male+1;}printf("%d %d\n",male,female+male+1);}return 0;}8.Checksum algorithm #include <>#include <>#include <>int main(){int i,n,t,j;char s[100][100];for(i=0;;i++){gets(s[i]);if(s[i][0]=='#') break;}n=i;for(i=0;i<n;i++){t=0;for(j=0;j<strlen(s[i]);j++)if(s[i][j]==32) t=t;else t=t+(j+1)*(s[i][j]-64);printf("%d\n",t);}return 0;}9.Coin Test#include <>#include <>int main(){char A[100000];int n,i=0,a=0,b=0,j;double x;while(1){scanf("%c",&A[i]);if(A[i]=='\n')break;i++;}for(j=0;j<i;j++){if(A[j]=='S'){printf("WA");goto OH;}if(A[j]=='U')a++;if(A[j]=='D')b++;}x=a*(a+b)*;if>||<printf("Fail");elseprintf("%d/%d",a,a+b);OH:return 0;}10.Dexter need help #include <>int fun(int a){if(a==1) return 1;elsereturn fun(a/2)+1; }int main(){int a,b[100],i=0,j; while(1){scanf("%d",&a);if(a==0)break;b[i]=fun(a);i++;}for(j=0;j<i;j++){ printf("%d\n",b[j]); }return 0;}11.Double#include <>#include <>int main(){int a[100],b[100],i,j,n,t=0;for(i=0;;i++){scanf("%d",&a[i]);if(a[i]==0) break;}n=i;for(i=0;i<n;i++)b[i]=2*a[i];for(i=0;i<n;i++)for(j=0;j<n;j++)if(a[i]==b[j]) t++;printf("%d",t);return 0;}12.Easy problem#include <>#include <>int main(){int N,i,n,j=0;scanf("%d",&N);for(i=2;i<N+1;i++){if((N+1)%i==0)j++;}printf("%d",j/2);return 0;}13.Favorite number #include <>#include <>#define MAXNUM 100000int prime_number = 0;int prime_list[MAXNUM]; bool is_prime[MAXNUM]; int ans[MAXNUM + 2];int dp[MAXNUM + 2];void set_prime() {int i, j;memset(is_prime, 0, sizeof(is_prime));for (i = 2; i < MAXNUM; i++) {if (is_prime[i] == 0) {prime_list[prime_number++] = i;if (i >= MAXNUM / i) continue;for (j = i * i; j < MAXNUM; j+=i) {is_prime[j] = 1;}}}}int main() {int i, j, k,o=0,d[100];memset(dp, -1, sizeof(dp));set_prime();ans[0] = 0;dp[1] = 0;for (i = 1; i <= MAXNUM; i++) {ans[i] = ans[i - 1] + dp[i];if (dp[i + 1] == -1 || dp[i + 1] > dp[i] + 1) {dp[i + 1] = dp[i] + 1;}for (j = 0; j < prime_number; j++) {if (i > MAXNUM / prime_list[j]) break;k = i * prime_list[j];if (dp[k] == -1 || dp[k] > dp[i] + 1) {dp[k] = dp[i] + 1;}}}while (scanf("%d%d", &i, &j) == 2 && (i || j)){ d[o]=ans[j] - ans[i - 1];o++;}for(i=0;i<o;i++)printf("%d\n",d[i]);}14.Graveyard#include <>#include <>#include <>int main(){int a[100],b[100],n,i,j;double s,p,l,t;for(i=0;;i++){scanf("%d%d",&a[i],&b[i]);if(a[i]==0&&b[i]==0) break;}n=i;for(i=0;i<n;i++){p=10000;if(b[i]%a[i]==0){printf("\n");continue;};t=10000/((double)a[i]);for(j=1;j<a[i]+b[i];j++){l=10000/((double)(a[i]+b[i]));l=t-j*l;l=fabs(l);if(l<p) p=l;}s=(a[i]-1)*p;printf("%.4lf\n",s);}return 0;}15.Hailstone#include <>#include <>#include <>int f(int n){int s=1;while(1){if(n==1) return s;else if(n%2==0) n=n/2,s++;else n=3*n+1,s++;}}int main(){int n,m,i,j=0,t;scanf("%d%d",&m,&n);printf("%d %d",m,n);if(m>n) t=m,m=n,n=t;for(i=m;i<=n;i++)if(f(i)>j) j=f(i);printf(" %d",j);return 0;}16.HanoiⅡ#include <>#include <>#define M 70int start[M], targe[M];long long f(int *p, int k, int fina) {if(k==0) return 0;if(p[k]==fina) return f(p,k-1,fina);return f(p,k-1,6-fina-p[k])+(1LL<<(k-1));}int main (){long long ans;int n;while(scanf("%d",&n),n){int i;for(i=1;i<=n;i++) scanf("%d",&start[i]);for(i=1;i<=n;i++) scanf("%d",&targe[i]);int c=n;for(;c>=1&&start[c]==targe[c];c--);if(c==0){printf("0\n"); continue;}int other=6-start[c]-targe[c]; ans=f(start,c-1,other)+f(targe,c-1,other)+1;printf("%lld\n",ans);}return 0;}17.Houseboat#include <>#include <>#include <>#define piint f(float x,float y){int i;for(i=0;;i++)if(50*i>sqrt(x*x+y*y)*sqrt(x*x+y*y)*pi/2) break;return i;}int main(){int n,i,a[100];float x,y;scanf("%d",&n);for(i=0;i<n;i++){scanf("%f%f",&x,&y);a[i]=f(x,y);}for(i=0;i<n;i++)printf("%d %d\n",i+1,a[i]);return 0;}18.Music Composer19.Redistribute wealth#include <>#include <>#include <>int main(){inta[1000],b[1000],n,i,j,s,sum,t,m,mid,c[100],k=0;while(1){scanf("%d",&n);if(n==0) break;{s=0;for(i=1;i<=n;i++){scanf("%d",&a[i]);s=s+a[i];}m=s/n;b[1]=a[1]-m;b[0]=0;for(i=2;i<n;++i)b[i]=b[i-1]+a[i]-m;for(i=0;i<n;i++)for(j=0;j<n-1-i;j++)if(b[j]>b[j+1])t=b[j],b[j]=b[j+1],b[j+1]=t;mid=b[n/2];sum=0;for(i=0;i<=n-1;++i) sum=sum+fabs(mid-b[i]);c[k]=sum;k++;}}for(i=0;i<k;i++) printf("%d\n",c[i]);return 0;}20.Road trip#include <>#include <>#include <>int f(int n){int a[100],b[100],i,s;for(i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);s=a[0]*b[0];for(i=1;i<n;i++)s=s+a[i]*(b[i]-b[i-1]);return s;}int main(){int n,c[100],i=0;while(1){scanf("%d",&n);if(n==-1) break;c[i]=f(n);i++;}n=i;for(i=0;i<n;i++)printf("%d\n",c[i]);return 0;}21.Scoring#include <>#include <>#include <>int main(){int i,j,sum,min,c,count,n,a,b; char s1[50],s2[50];scanf("%d",&n);for(i=0;i<n;i++){count=sum=0;scanf("%s",s2);for(j=0;j<4;j++){scanf("%d%d",&a,&b);if(b!=0){sum+=(a-1)*20+b;count++;}}if(i==0){c=count,min=sum;strcpy(s1,s2);}else if(count>c||(count==c&&sum<min)) {min=sum;c=count;strcpy(s1,s2);}}printf("%s %d %d\n",s1,c,min); return 0;}22.Specialized Numbers#include <>#include <>int main(){int i,n,sum10,sum12,sum16;for(i=2992;i<3000;i++){n=i;sum10=0;while(n){sum10+=n%10;n/=10;}n=i;sum12=0;while(n){sum12+=n%12;n/=12;}n=i;sum16=0;while(n){sum16+=n%16;n/=16;}if(sum10==sum12&&sum12==sum16) printf("%d\n",i);}return 0;}23.Sticks#include <>#include <>#include <>int len[64], n, minlen, get;bool b[64];int cmp(const void *a, const void *b) {return *(int *)a < *(int *)b 1 : -1;}bool dfs(int nowlen, int nowget, int cnt) {if(cnt >= n) return false;if(get == nowget) return true;int i;bool f = false;if(nowlen == 0) f = true;for(i = cnt; i < n; i++){if(!b[i]){if(len[i] + nowlen == minlen){b[i] = true;if(dfs(0, nowget+1, nowget))return true;b[i] = false;return false;}else if(len[i] + nowlen < minlen){b[i] = true;if(dfs(nowlen+len[i], nowget, i+1))return true;b[i] = false;if(f) return false;while(i+ 1 < n && len[i] == len[i+1]) i++;}}}return false;}int main(){int i, tollen;while(scanf("%d", &n), n){tollen = 0;int j = 0, p;for(i = 0; i < n; i++){scanf("%d", &p);if(p <= 50){len[j] = p;tollen += len[j];j++;}}n = j;if(n == 0){printf("0\n");continue;}qsort(len, n, sizeof(int), cmp); for(minlen = len[0]; ; minlen++) {if(tollen % minlen) continue;memset(b, 0, sizeof(b));get = tollen / minlen;if(dfs(0, 0, 0)){printf("%d\n", minlen);break;}}}return 0;}24.Sum of Consecutive#include <>#include <>#include <>int len[64],n,minlen,get;int b[64];int cmp(const void *a,const void *b) {return *(int *)a<*(int *)b1:-1;}int dfs(int nowlen,int nowget,int cnt){if(cnt>=n) return 0;if(get==nowget) return 1;int i,f=0;if(nowlen==0) f=1;for(i=cnt;i<n;i++){if(len[i]+nowlen==minlen){b[i]=1;if(dfs(0,nowget+1,nowget)) return 1;b[i]=0;return 0;}else if(len[i]+nowlen<minlen){b[i]=1;if(dfs(nowlen+len[i],nowget,i+1)) return 1;b[i]=0;if(f) return 0;while(i+1<n&&len[i]==len[i+1]) i++;}}return 0;}int main(){int i,tollen,q=0,c[100];while(scanf("%d",&n),n){tollen=0;int j=0,p;for(i=0;i<n;i++){scanf("%d",&p);if(p<=50){len[j]=p;tollen+=len[j];j++;}}n=j;if(n==0){printf("0\n");continue;}qsort(len,n,sizeof(int),cmp);for(minlen=len[0];;minlen++){if(tollen%minlen) continue;memset(b,0,sizeof(b));get=tollen/minlen;if(dfs(0,0,0)){c[q]=minlen;q++;break;}}}for(i=0;i<q;i++)printf("%d\n",c[i]);return 0;}25.Symmetric Sort#include <>#include <>#include <>int main(){double A[100];int i=0,j=0,k=0,l=0,sum=0;while(1){scanf("%lf",&A[i]);if(A[i]==0)break;i++;}for(j=0;j<i;j++){if(A[j]==2)printf("1\n");else{int B[10000],m=1,number=0;double n;B[0]=2;for(k=3;k<=A[j];k+=2){n=(double)k;for(l=2;l<=sqrt(n);l++){if(k%l==0)goto ai;}B[m]=k;m++;ai:;}for(k=0;k<m;k++){sum=0;for(l=k;l<m;l++){sum+=B[l];if(sum==A[j]){number++;break;}}}printf("%d\n",number);}}return 0;}26.The Clock#include <>#include <>#include <>int main(){char s[100][100],a[100];int i,j,n;scanf("%d",&n);for(i=0;i<n;i++) scanf("%s",s[i]);for(i=0;i<n-1;i++)for(j=0;j<n-1-i;j++)if(strlen(s[i])>strlen(s[i+1]))strcpy(a,s[i]),strcpy(s[i],s[i+1]),strcpy(s[i+1],a) ;if(n%2==0){for(i=0;i<n-1;i=i+2) printf("%s ",s[i]);printf("%s ",s[n-1]);for(i=i-3;i>0;i=i-2) printf("%s ",s[i]);}else{for(i=0;i<n-1;i=i+2) printf("%s ",s[i]);printf("%s ",s[n-1]);for(i=i-1;i>0;i=i-2) printf("%s ",s[i]);}return 0;}27.The Ratio of gainers to losers #include<>int main(){char s[5];int i,sum=0;gets(s);for(i=0;s[i]!='\0';i++){switch(s[i]){case'I': sum+=1;break; case'V': sum=5-sum;break; case'X':sum=10-sum;break; }}printf("%d\n",sum);return 0;}28.VOL大学乒乓球比赛#include <>#include <>int main(){printf("A=Z\nB=X\nC=Y\n");return 0;}29.毕业设计论文打印#include <>#include <>int main(){int a[100],j=1,i,n,m;scanf("%d%d",&n,&m);for(i=0;i<n;i++)scanf("%d",&a[i]);for(i=0;i<n;i++)if(a[i]>a[m]) j++;printf("%d",j++);return 0;}30.边沿与内芯的差#include <>#include <>int main(){int A[100][100],i,j,m,n,s=0,t=0;scanf("%d%d",&n,&m);for(i=1;i<=n;i++){for(j=1;j<=m;j++){scanf("%d",&A[i][j]);}。
西工大noj问题详解解析汇报(完整版)
西北工业大学POJ答案绝对是史上最全版(不止100题哦……按首字母排序)1.“1“的传奇2.A+B3.A+BⅡ4.AB5.ACKERMAN6.Arithmetic Progressions7.Bee8.Checksum algorithm9.Coin Test10.Dexter need help11.Double12.Easy problem13.Favorite number14.Graveyard15.Hailstone16.Hanoi Ⅱ17.Houseboat18.Music Composer19.Redistribute wealth20.Road trip21.Scoring22.Specialized Numbers23.Sticks24.Sum of Consecutive25.Symmetric Sort26.The Clock27.The Ratio of gainers to losers28.VOL大学乒乓球比赛29.毕业设计论文打印30.边沿与内芯的差31.不会吧,又是A+B32.不屈的小蜗33.操场训练34.插入链表节点35.插入排序36.插入字符37.成绩表计算38.成绩转换39.出租车费40.除法41.创建与遍历职工链表42.大数乘法43.大数除法44.大数加法45.单词频次46.迭代求根47.多项式的猜想48.二分查找49.二分求根50.发工资的日子51.方差52.分离单词53.分数拆分54.分数化小数55.分数加减法56.复数57.高低交换58.公园喷水器59.韩信点兵60.行程编码压缩算法61.合并字符串62.猴子分桃63.火车站64.获取指定二进制位65.积分计算66.级数和67.计算A+B68.计算PI69.计算π70.计算成绩71.计算完全数72.检测位图长宽73.检查图像文件格式74.奖金发放75.阶乘合计76.解不等式77.精确幂乘78.恐怖水母79.快速排序80.粒子裂变81.链表动态增长或缩短82.链表节点删除83.两个整数之间所有的素数84.路痴85.冒泡排序86.你会存钱吗87.逆序整数88.排列89.排列分析90.平均值函数91.奇特的分数数列92.求建筑高度93.区间内素数94.三点顺序95.山迪的麻烦96.删除字符97.是该年的第几天98.是该年的第几天?99.数据加密100.搜索字符101.所有素数102.探索合数世纪103.特殊要求的字符串104.特殊整数105.完全数106.王的对抗107.危险的组合108.文件比较109.文章统计110.五猴分桃111.小型数据库112.幸运儿113.幸运数字”7“114.选择排序115.寻找规律116.循环移位117.延伸的卡片118.羊羊聚会119.一维数组”赋值“120.一维数组”加法“121.勇闯天涯122.右上角123.右下角124.圆及圆球等的相关计算125.圆及圆球等相关计算126.程序员添加行号127.找出数字128.找幸运数129.找最大数130.整数位数131.重组字符串132.子序列的和133.子字符串替换134.自然数立方的乐趣135.字符串比较136.字符串复制137.字符串加密编码138.字符串逆序139.字符串排序140.字符串替换141.字符串左中右142.组合数143.最次方数144.最大乘积145.最大整数146.最小整数147.最长回文子串148.左上角149.左下角1.“1“的传奇#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){int n,i,j,k=0,x=1,y,z,m,p,q,a,s=0;scanf("%d",&n);m=n;for(i=1;i<12;i++){m=m/10;k++;if(m==0)break;}q=n;k=k-1;for(a=1;a<=k;a++){x=x*10;}y=q%x;z=q/x;p=q-y;if(z>=2)s=s+x+z*k*(x/10); elses=s+z*k*(x/10); for(j=p;j<=n;j++) {m=j;for(i=1;i<12;i++){x=m%10;if(x==1)s++;m=m/10;if(m==0)break;}}printf("%d",s);return 0;}2.A+B#include <stdio.h>int doubi(int n,int m){n=n+m;n=n%100;return n;}int main(){int t,i,a[100],n,m;scanf("%d",&t);for (i=0;i<=(t-1);i++){scanf("%d%d",&n,&m);a[i]=doubi(n,m);}for (i=0;i<=(t-1);i++)printf("%d\n",a[i]);return 0;}3.A+BⅡ#include <stdio.h>int main(){int A,B,sum;scanf("%d%d",&A,&B);sum=A+B;printf("%d\n",sum);return 0;}4.AB#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){char s[100],q[100];double a,b,c;int n=0,i;scanf("%lf%lf",&a,&b);c=a*b;sprintf(s,"%.0lf",c);for(i=0;i<strlen(s);i++){n=n+s[i]-48;}while(n>=10){sprintf(q,"%d",n);n=0;for(i=0;i<strlen(q);i++)n=n+q[i]-48;}printf("%d",n);return 0;}5.ACKERMAN#include <stdio.h>#include <stdlib.h>int ack(int x,int y){int n;if (x==0) {n=y+1;return n;}else if (y==0) n=ack(x-1,1);else n=ack(x-1,ack(x,y-1));return n;}int main(){int m,b;scanf("%d%d",&m,&b);m=ack(m,b);printf("%d",m);return 0;}6.Arithmetic Progressions#include <stdio.h>#include <math.h>int g(int n){int i;if(n==1) return 0;if(n==2) return 1;if(n==3) return 1;for(i=2;i<=sqrt(n);i++) if(n%i==0) return 0;return 1;}int f(int a,int b,int c){int i=0,s=a-b;if(c==1&&g(a)==1) return a;if(b==0&&g(a)!=1) return -1;while(1){s=s+b;if(g(s)) i++;if(i>=c) break;}return s;int main(){int a,b,c,d[100],i=0,n;while(1){scanf("%d%d%d",&a,&b,&c);if(a==0&&b==0&&c==0) break;d[i]=f(a,b,c);i++;}n=i;for(i=0;i<n;i++)printf("%d\n",d[i]);return 0;}7.Bee#include <stdio.h>#include <stdlib.h>int main()int A[100],i=0,j,k,female=0,male=1,x;for(;;i++){scanf("%d",&A[i]);if(A[i]==-1)break;}for(j=0;j<i;j++){female=0,male=1;for(k=1;k<A[j];k++){x=female;female=male;male=x+male+1;}printf("%d %d\n",male,female+male+1);}return 0;}8.Checksum algorithm#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){int i,n,t,j;char s[100][100];for(i=0;;i++){gets(s[i]);if(s[i][0]=='#') break;}n=i;for(i=0;i<n;i++){t=0;for(j=0;j<strlen(s[i]);j++)if(s[i][j]==32) t=t;else t=t+(j+1)*(s[i][j]-64);printf("%d\n",t);}return 0;}9.Coin Test#include <stdio.h>#include <stdlib.h>int main(){char A[100000];int n,i=0,a=0,b=0,j;double x;while(1){scanf("%c",&A[i]);if(A[i]=='\n')break;i++;}for(j=0;j<i;j++){if(A[j]=='S'){printf("WA");goto OH;}if(A[j]=='U')a++;if(A[j]=='D')b++;}x=a*1.0/(a+b)*1.0;if(x-0.5>0.003||x-0.5<-0.003) printf("Fail");elseprintf("%d/%d",a,a+b);OH:return 0;}10.Dexter need help#include <stdio.h>int fun(int a){if(a==1) return 1;elsereturn fun(a/2)+1;}int main(){int a,b[100],i=0,j; while(1){scanf("%d",&a);if(a==0)break;b[i]=fun(a);i++;}for(j=0;j<i;j++){printf("%d\n",b[j]); }return 0;}11.Double#include <stdio.h>#include <stdlib.h>int main(){int a[100],b[100],i,j,n,t=0;for(i=0;;i++){scanf("%d",&a[i]);if(a[i]==0) break;}n=i;for(i=0;i<n;i++)b[i]=2*a[i];for(i=0;i<n;i++)for(j=0;j<n;j++)if(a[i]==b[j]) t++;printf("%d",t);return 0;}12.Easy problem#include <stdio.h>#include <math.h>int main(){int N,i,n,j=0;scanf("%d",&N);for(i=2;i<N+1;i++){if((N+1)%i==0)j++;}printf("%d",j/2);return 0;}13.Favorite number #include <stdio.h>#include <string.h>#define MAXNUM 100000int prime_number = 0;int prime_list[MAXNUM]; bool is_prime[MAXNUM]; int ans[MAXNUM + 2];int dp[MAXNUM + 2];void set_prime() {int i, j;memset(is_prime, 0, sizeof(is_prime));for (i = 2; i < MAXNUM; i++) {if (is_prime[i] == 0) {prime_list[prime_number++] = i;if (i >= MAXNUM / i) continue;for (j = i * i; j < MAXNUM; j+=i) {is_prime[j] = 1;}}}}int main() {int i, j, k,o=0,d[100];memset(dp, -1, sizeof(dp));set_prime();ans[0] = 0;dp[1] = 0;for (i = 1; i <= MAXNUM; i++) {ans[i] = ans[i - 1] + dp[i];if (dp[i + 1] == -1 || dp[i + 1] > dp[i] + 1) {dp[i + 1] = dp[i] + 1;}for (j = 0; j < prime_number; j++) {if (i > MAXNUM / prime_list[j]) break;k = i * prime_list[j];if (dp[k] == -1 || dp[k] > dp[i] + 1) {dp[k] = dp[i] + 1;}}}while (scanf("%d%d", &i, &j) == 2 && (i || j)) { d[o]=ans[j] - ans[i - 1];o++;}for(i=0;i<o;i++)printf("%d\n",d[i]);}14.Graveyard#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){int a[100],b[100],n,i,j;double s,p,l,t;for(i=0;;i++){scanf("%d%d",&a[i],&b[i]);if(a[i]==0&&b[i]==0) break;}n=i;for(i=0;i<n;i++){p=10000;if(b[i]%a[i]==0){printf("0.0000\n");continue;};t=10000/((double)a[i]);for(j=1;j<a[i]+b[i];j++){l=10000/((double)(a[i]+b[i]));l=t-j*l;l=fabs(l);if(l<p) p=l;}s=(a[i]-1)*p;printf("%.4lf\n",s);}return 0;}15.Hailstone#include <stdio.h>#include <stdlib.h>#include <string.h>int f(int n){int s=1;while(1){if(n==1) return s;else if(n%2==0) n=n/2,s++;else n=3*n+1,s++;}}int main()int n,m,i,j=0,t;scanf("%d%d",&m,&n);printf("%d %d",m,n);if(m>n) t=m,m=n,n=t;for(i=m;i<=n;i++)if(f(i)>j) j=f(i);printf(" %d",j);return 0;}16.Hanoi Ⅱ#include <stdio.h>#include <stdlib.h>#define M 70int start[M], targe[M];long long f(int *p, int k, int fina){if(k==0) return 0;if(p[k]==fina) return f(p,k-1,fina); return f(p,k-1,6-fina-p[k])+(1LL<<(k-1));int main (){long long ans;int n;while(scanf("%d",&n),n){int i;for(i=1;i<=n;i++) scanf("%d",&start[i]);for(i=1;i<=n;i++) scanf("%d",&targe[i]);int c=n;for(;c>=1&&start[c]==targe[c];c--);if(c==0){printf("0\n"); continue;}int other=6-start[c]-targe[c];ans=f(start,c-1,other)+f(targe,c-1,other)+1;printf("%lld\n",ans);}return 0;}17.Houseboat#include <stdio.h>#include <stdlib.h>#include <math.h>#define pi 3.1415926int f(float x,float y){int i;for(i=0;;i++)if(50*i>sqrt(x*x+y*y)*sqrt(x*x+y*y)*pi/2) break;return i;}int main(){int n,i,a[100];float x,y;scanf("%d",&n);for(i=0;i<n;i++){scanf("%f%f",&x,&y);a[i]=f(x,y);}for(i=0;i<n;i++)printf("%d %d\n",i+1,a[i]);return 0;}18.Music Composer19.Redistribute wealth#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){int a[1000],b[1000],n,i,j,s,sum,t,m,mid,c[100],k=0;while(1){scanf("%d",&n);if(n==0) break;{s=0;for(i=1;i<=n;i++){scanf("%d",&a[i]);s=s+a[i];}m=s/n;b[1]=a[1]-m;b[0]=0;for(i=2;i<n;++i)b[i]=b[i-1]+a[i]-m;for(i=0;i<n;i++)for(j=0;j<n-1-i;j++)if(b[j]>b[j+1]) t=b[j],b[j]=b[j+1],b[j+1]=t;mid=b[n/2];sum=0;for(i=0;i<=n-1;++i) sum=sum+fabs(mid-b[i]);c[k]=sum;k++;}}for(i=0;i<k;i++) printf("%d\n",c[i]);return 0;}20.Road trip#include <stdio.h>#include <stdlib.h>#include <math.h>int f(int n){int a[100],b[100],i,s;for(i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);s=a[0]*b[0];for(i=1;i<n;i++)s=s+a[i]*(b[i]-b[i-1]);return s;}int main(){int n,c[100],i=0;while(1){scanf("%d",&n);if(n==-1) break;c[i]=f(n);i++;}n=i;for(i=0;i<n;i++)printf("%d\n",c[i]);return 0;}21.Scoring#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){int i,j,sum,min,c,count,n,a,b;char s1[50],s2[50];scanf("%d",&n);for(i=0;i<n;i++){count=sum=0;scanf("%s",s2);for(j=0;j<4;j++){scanf("%d%d",&a,&b);if(b!=0){sum+=(a-1)*20+b;count++;}}if(i==0){c=count,min=sum;strcpy(s1,s2);}else if(count>c||(count==c&&sum<min)){min=sum;c=count;strcpy(s1,s2);}}printf("%s %d %d\n",s1,c,min);return 0;}22.Specialized Numbers#include <stdio.h>#include <stdlib.h>int main(){int i,n,sum10,sum12,sum16;for(i=2992;i<3000;i++){n=i;sum10=0;while(n){sum10+=n%10;n/=10;}n=i;sum12=0;while(n){sum12+=n%12;n/=12;}n=i;sum16=0;while(n){sum16+=n%16;n/=16;}if(sum10==sum12&&sum12==sum16) printf("%d\n",i);}return 0;}23.Sticks#include <stdio.h>#include <string.h>#include <stdlib.h>int len[64], n, minlen, get;bool b[64];int cmp(const void *a, const void *b){return *(int *)a < *(int *)b ? 1 : -1;}bool dfs(int nowlen, int nowget, int cnt){if(cnt >= n) return false;if(get == nowget) return true;int i;bool f = false;if(nowlen == 0) f = true;for(i = cnt; i < n; i++){if(!b[i]){if(len[i] + nowlen == minlen){b[i] = true;if(dfs(0, nowget+1, nowget))return true;b[i] = false;return false;}else if(len[i] + nowlen < minlen){b[i] = true;if(dfs(nowlen+len[i], nowget, i+1))return true;b[i] = false;if(f) return false;while(i + 1 < n && len[i] == len[i+1]) i++;}}}return false;}int main(){int i, tollen;while(scanf("%d", &n), n){tollen = 0;int j = 0, p;for(i = 0; i < n; i++){scanf("%d", &p);if(p <= 50)len[j] = p;tollen += len[j];j++;}}n = j;if(n == 0){printf("0\n");continue;}qsort(len, n, sizeof(int), cmp);for(minlen = len[0]; ; minlen++) {if(tollen % minlen) continue;memset(b, 0, sizeof(b));get = tollen / minlen;if(dfs(0, 0, 0)){printf("%d\n", minlen);break;}}return 0;}24.Sum of Consecutive#include <stdio.h>#include <stdlib.h>#include <string.h>int len[64],n,minlen,get;int b[64];int cmp(const void *a,const void *b) {return *(int *)a<*(int *)b?1:-1; }int dfs(int nowlen,int nowget,int cnt) {if(cnt>=n) return 0;if(get==nowget) return 1;int i,f=0;if(nowlen==0) f=1;for(i=cnt;i<n;i++){if(len[i]+nowlen==minlen){b[i]=1;if(dfs(0,nowget+1,nowget)) return 1;b[i]=0;return 0;}else if(len[i]+nowlen<minlen){b[i]=1;if(dfs(nowlen+len[i],nowget,i+1)) return 1;b[i]=0;if(f) return 0;while(i+1<n&&len[i]==len[i+1]) i++;}}return 0;}int main(){int i,tollen,q=0,c[100];while(scanf("%d",&n),n){tollen=0;int j=0,p;for(i=0;i<n;i++){scanf("%d",&p);if(p<=50){len[j]=p;tollen+=len[j];j++;}}n=j;if(n==0){printf("0\n"); continue;}qsort(len,n,sizeof(int),cmp); for(minlen=len[0];;minlen++){ if(tollen%minlen) continue;memset(b,0,sizeof(b));get=tollen/minlen;if(dfs(0,0,0)){c[q]=minlen;q++;break;}}}for(i=0;i<q;i++)printf("%d\n",c[i]);return 0;}25.Symmetric Sort#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){double A[100];int i=0,j=0,k=0,l=0,sum=0;while(1){scanf("%lf",&A[i]);if(A[i]==0)break;i++;}for(j=0;j<i;j++){if(A[j]==2)printf("1\n");else{int B[10000],m=1,number=0;double n;B[0]=2;for(k=3;k<=A[j];k+=2){n=(double)k;for(l=2;l<=sqrt(n);l++){if(k%l==0)goto ai;}B[m]=k;m++;ai:;}for(k=0;k<m;k++){sum=0;for(l=k;l<m;l++){sum+=B[l];if(sum==A[j]){number++;break;}}}printf("%d\n",number);}}return 0;}26.The Clock#include <stdio.h>#include <stdlib.h>#include <string.h>int main()char s[100][100],a[100];int i,j,n;scanf("%d",&n);for(i=0;i<n;i++) scanf("%s",s[i]);for(i=0;i<n-1;i++)for(j=0;j<n-1-i;j++)if(strlen(s[i])>strlen(s[i+1]))strcpy(a,s[i]),strcpy(s[i],s[i+1]),strcpy(s[i+1],a);if(n%2==0){for(i=0;i<n-1;i=i+2) printf("%s ",s[i]);printf("%s ",s[n-1]);for(i=i-3;i>0;i=i-2) printf("%s ",s[i]);}else{for(i=0;i<n-1;i=i+2) printf("%s ",s[i]);printf("%s ",s[n-1]);for(i=i-1;i>0;i=i-2) printf("%s ",s[i]);}return 0;}27.The Ratio of gainers to losers #include<stdio.h>int main(){char s[5];int i,sum=0;gets(s);for(i=0;s[i]!='\0';i++){switch(s[i]){case'I': sum+=1;break;case'V': sum=5-sum;break; case'X':sum=10-sum;break; }}printf("%d\n",sum);return 0;}28.VOL大学乒乓球比赛#include <stdio.h>#include <stdlib.h>int main(){printf("A=Z\nB=X\nC=Y\n");return 0;}29.毕业设计论文打印#include <stdio.h>#include <stdlib.h>int main(){int a[100],j=1,i,n,m;scanf("%d%d",&n,&m);for(i=0;i<n;i++)scanf("%d",&a[i]);for(i=0;i<n;i++)if(a[i]>a[m]) j++;printf("%d",j++);return 0;}30.边沿与内芯的差#include <stdio.h>#include <stdlib.h>int main(){int A[100][100],i,j,m,n,s=0,t=0;scanf("%d%d",&n,&m);for(i=1;i<=n;i++){for(j=1;j<=m;j++){scanf("%d",&A[i][j]);}}for(i=2;i<m;i++)s=s+A[1][i];for(i=2;i<m;i++)s=s+A[n][i];for(i=1;i<=n;i++)s=s+A[i][1];for(i=1;i<=n;i++)。
西北工业大学机械原理课后答案第3章
O OO OP 2P 3F 23(P 24Pl 3(P 34)(a)(b)Pl 3Pl 6A 1题3-6在图a 所示的四杆机构中,第三章平面机构的运动分析题3-3试求图示各机构在图示位置时全部瞬心的位置(用符号P j 直接标注在图上)解:题3-4在图示在齿轮-连杆机构中,试用瞬心法求齿轮1与齿轮3的传动比w1/w3.C 2P 12P 23St -解:1)计算此机构所有瞬心的数目K N (N1)2152) 为求传动比 < 3需求出如下三个瞬心 R 6、P 36、P 13如图3-2所示。
; 1 巳6只33) 传动比 仁3计算公式为: —3P 16P 13I AB =60mm , l cD =90mm , l AD =|Bc =120mm , w 2=10rad/s ,试用瞬心P134 C 4L CP 12AM B3P iP 34CBMF 24F 34P ?4(d)Pl 4法求:V B3I AB2IAB lBPI32.56rad sV ClCR 3 3 0.4m s量得 1 26.42 226.6P 3434B P 233 22A ,D- i Pl4P 12 1(a)P 131) 当0 =165。
时,点C 的速度Vc ;2) 当$ =165。
时,构件3的BC 线上速度最小的一点 E 的位置及速度的大小; 3) 当Vc=O 时,0角之值(有两个解)解:1)以选定比例尺,绘制机构运动简图。
(图3-3 )2)求V c ,定出瞬心P 13的位置。
如图 3-3 (a )3)定出构件3的BC 线上速度最小的点 E 的位置。
因为BC 线上速度最小的点必与 P 13点的距离最近,所以过 P 13点引BC 线延长线的垂线交于 E 点。
如图3-3 (a )v E1ER 3 3 0.375ms4)当V C 0时,P 13与C 点重合,即AB 与BC 共线有两个位置。
作出 V C 0的两个位置。
题3-12在图示的各机构中,设已知各构件的尺寸、原动件 1以等角速度3 1顺时针方向转动。
西工大noj答案
西工大noj答案【篇一:西工大poj100题(全新)】圆及圆球等的相关计算#includestdio.hint main(){int a,b,sum;scanf(%d %d,a,b);sum=a+b;printf(%d,sum); }#includestdio.hint main(){float r,h,l,s,sq,vq,vz,pi=3.141592653; scanf(%f %f,r,h);l=2*pi*r;s=pi*r*r;【篇二:西北工业大学 c语言 poj题目及答案_第一季】>毋庸置疑,学习程序设计就是奔着“程序员梦”去的。
编程本质是运用计算机科学的基本思想求解问题、设计系统以及理解人类的思维行为和普适技能,核心是“实现”。
因此,诸如“中国梦”、“程序员梦”是编写出来,即“coding now,programming future”。
在这个学期,你将尝试用“编写”的方式去“实现”,体验与过去完全不同的“实现”。
在这个过程中,有太多的“if”不确定、有太多的“for”死循环、有太多的“bug”愁断魂,“实现”并不容易。
有人的地方就有江湖,有江湖的地方就有武林大会。
poj(problems online judge)是学编程的江湖。
在这里,做习题叫做“刷题”,习题做错叫做“被挖”(wa=wrong answer,结果错误),习题通过叫做“a了”(ac=accepted,结果通过),简单习题称为“水题”,“刷一圈”指连续刷题12小时以上。
总会有人用一、两周的时间完成100题的oj,这不叫“刷题”,叫“梦游”。
2012学年,一个大三的哥哥将100题的源码整理出版了(长安校区超市旁的复印店),大一亲们蜂拥而至,一时间“a4纸贵”,交叉着下载、复制、粘贴、上传的能力训练,唯独不见“编写”。
待到期末上机考试,亲们那双瞠目的眼睛与希望工程那双大眼睛神似,最终贡献了两位数的gdp。
有道是出来混的,迟早要还,哥哥今昔完美毕业,亲们继续“梦游”。
西工大C语言POJ习题答案之欧阳引擎创编
一.1.第一季10题全(注:第五题问题已经解决,确认AC!)欧阳引擎(2021.01.01)#include <stdio.h>int main(){int a,b,sum;scanf("%d%d",&a,&b);sum=a+b;printf("%d\n",sum);return 0;}2.#include <stdio.h>#define PI 3.1415926int main(){double r,h,l,s,sq,vq,vz;scanf("%lf%lf",&r,&h);l=2*PI*r;s=PI*r*r;sq=4*PI*r*r;vq=4*PI*r*r*r/3;vz=s*h;printf("%.2lf\n%.2lf\n%.2lf\n%.2lf\n%.2lf\n",l,s,sq ,vq,vz); return 0;}3.#include <stdio.h>int main(){int a,b,c;double d,e;scanf("%d%d%d",&a,&b,&c);d=a+b+c;e=d/3;printf("%lf\n%lf\n",d,e);return 0;}4.#include <stdio.h>int main(){int a,b,c;scanf("%d%d%d",&a,&b,&c);if(a<b)a=b;if(a<c)a=c;printf("%d\n",a);return 0;}5.#include<stdio.h>int main(){int i=0,j=0,k=1;char a[6];while((a[i]=getchar())!='\n'){ i++;}for(;i>0;i--){if(a[j]==a[i-1]){j++;continue;}else {k=0;break;}}if(k==1)printf("yes\n");elseprintf("no\n"); }6.#include<stdio.h>int main(){double a,c;scanf("%lf",&a);switch((int)a/10){case 0:c=a*0.1;break;case 1:c=(a-10)*0.075+10*0.1;break;case 2:case 3:c=(a-20)*0.05+10*0.075+10*0.1;break;case 4: case 5:c=(a-40)*0.03+20*0.05+10*0.075+10*0.1;break;case 6:case 7:case 8:case 9:c=(a-60)*0.015+20*0.03+20*0.05+10*0.075+10*0.1;break;default:c=(a-100)*0.01+40*0.015+20*0.03+20*0.05+10*0.075+10*0.1;}printf("%lf\n",c);return 0;}7.#include<stdio.h>int main(){double a,b,c;scanf("%lf",&a);c=(int)a;if(a>c)a=c+1;if(a>15)b=(a-15)*2.1+7+13*1.5;else {if(a>2)b=(a-2)*1.5+7;else b=7; } printf("%lf\n",b);return 0;}8.#include <stdio.h>int main(){int a,b,c,e,f=30,g=31,n;scanf("%d-%d-%d",&a,&b,&c);if((a%400==0)||(a%100!=0&&a%4==0))e=29;elsee=28;switch (b){case 1:n=c;break;case 2:n=g+c;break;case 3:n=g+e+c;break; case 4:n=g+e+g+c;break;case 5:n=g+e+g+f+c;break;case 6:n=g+e+g+f+g+c;break;case 7:n=g+e+g+f+g+f+c;break;case 8:n=g+e+g+f+g+f+g+c;break;case 9:n=g+e+g+f+g+f+g+g+c;break;case 10:n=g+e+g+f+g+f+g+g+f+c;break;case 11:n=g+e+g+f+g+f+g+g+f+g+c;break;default: n=g+e+g+f+g+f+g+g+f+g+f+c;}printf("%d\n",n);return 0;}9.#include <stdio.h>int main(){int x;scanf("%d",&x);if(x>=90&&x<=100)printf("A\n");else if (x>=80)printf("B\n");else if (x>=70)printf("C\n");else if (x>=60)printf("D\n");elseprintf("E\n");return 0;}10.#include<stdio.h>int main(){double x,y,s;scanf("%lf,%lf",&x,&y);s=(x+2)*(x+2)+(y-2)*(y-2);if(s>1){s=(x+2)*(x+2)+(y+2)*(y+2);if(s>1){ s=(x-2)*(x-2)+(y+2)*(y+2);if(s>1){s=(x-2)*(x-2)+(y-2)*(y-2);if(s>1){printf("0\n");return 1;}}}}printf("10\n");return 0;}二。
西工大NOJ答案完全版
输出A+B的结黑#i nclude<stdio.h>int main(){int a,b,sum;sca nf("%d%d",&a,&b);sum=a+b;prin tf("%d\n",sum); return 0; }#i nclude<stdio.h>#define PI 3.1415926int main(){double r,h,l,s,sq,vq,vz;sca nf("%lf%lf",&r,&h);l=2*PI*r;s=p|*r*r;sq=4*p|*r*r;vq=PI*r*r*r*4/3;vz=PI*r*r*h;prin tf("%.2lf\n%.2lf\n%.2lf\n%.2lf\n%.2lf\n",l,s,sq,vq,vz); return 0;}#i nclude<stdio.h>int main(){double ma,e ng,c,sum,ave;sca nf("%lf%lf%lf",&ma,&en g,&c); sum=ma+e ng+c; ave=sum/3;prin tf("%lf\n %lf\n",sum,ave); return 0;}#i nclude<stdio.h>int main(){int a,b,c,m;sca nf("%d%d%d",&a,&b,&c); if (a>b) m=a;else m=b;if (m<c) m=c;prin tf("%d",m);return 0;}#i nclude<stdio.h>int main(){int n;sca nf("%d",&n);if ((1000V n<10000)&&(n/1000==n%10)&&(n/100%10==n/10%10)) prin tf("y es\n");else if((100<n<=1000)&&(n/100==n%10)) printf("yes\n");else if((10< n <=100)&&(n/10==n%10)) pri ntf("yes\n");else if(0< n<=10) pri ntf("yes\n");else prin tf(" no\n");return 0;}#i nclude<stdio.h>int main(){double l,b on;sca nf("%lf",&l);if(|v=10) bon=1*0.1;else if(l<20) bo n=1+(l-10)*0.075; else if(l<40) bon=1.75+(1-20)*0.05; else if(l<60) bon=2.75+(1-40)*0.03; else if(l<100) bon=3.35+(1-60)*0.015; else bo n=3.95+(l-100)*0.01;prin tf("%lf\n",bo n);return 0;}输出为实型,帰留六惶小裁(单位为元)#i nclude<stdio.h>int main(){double d,m;sca nf("%lf",&d);if(d<=2) m=7;else if(d<=15){if(d-2==(i nt)(d-2)) m=7+(d-2)*1.5;else m=7+((i nt)(d-2)+1)*1.5;}else if(d-15==(int)(d-15)) m=26.5+(d-15)*2.1; else m=26.5+((i nt)(d-15)+1)*2.1;prin tf("%lf\n",m);return 0;}#i nclude<stdio.h>int main(){int y,m,d,Days,sum;sca nf("%d-%d-%d", &y,&m,&d);if((y%4==0&&y%100!=0)||(y%400==0)) Days=29; else Days=28; switch(m){case 1:sum=d;break;case 2:sum=31+d;break;case 3:sum=31+Days+d;break;case 4:sum=62+Days+d;break;case 5:sum=92+Days+d;break;case 6:sum=123+Days+d;break;case 7:sum=153+Days+d;break;case 8:sum=184+Days+d;break;case 9:sum=215+Days+d;break;case 10:sum=245+Days+d;break;case 11:sum=276+Days+d;break;case 12:sum=307+Days+d;break;}prin tf("%d\n",sum);return 0;}#i nclude<stdio.h>int main(){int i;sca nf("%d",&i);if(i>=90) prin tf("A\n");else if(i>=80) prin tf("B\n"); else if(i>=70) pri ntf("C\n"); else if(i>=60) prin tf("D\n"); else prin tf("E\n");return 0;}#i nclude<stdio.h>int main(){double x,y;sca nf("%lf,%lf", &x,&y);if((x-2)*(x-2)+(y-2)*(y-2)v=1) prin tf("10");else if((x-2)*(x-2)+(y+2)*(y+2)<=1) printf("10"); else if((x+2)*(x+2)+(y-2)*(y-2)<=1) printf("10"); else if((x+2)*(x+2)+(y+2)*(y+2)<=1) printf("10"); else prin tf("0");return 0;}输出根炬型・保留两性呷数.#i nclude<stdio.h>int main(){double l,x,r;sca nf("%lf %lf",&l,&r);while((2*l*l*l-4*l*l+3*l-6)!=0&&(2*r*r*r-4*r*r+3*r-6)!=0){ x=(l+r)/2;if((2*l*l*l-4*l*l+3*l-6)*(2*x*x*x-4*x*x+3*x-6)<=0)r=x;else l=x;}if(2*l*l*l-4*l*l+3*l-6==0) prin tf("%.2lf",l);else prin tf("%.2lf",r);return 0;}}#i nclude<stdio.h>#in clude<math.h>int main(){int i=800,t=2,c nt=0,sum=0;double e=-1;while(i>=500){while(t<=i-1){if(i%t==0) break;t++;}if(t==i) e=pow(-1,c nt),sum=sum+e*i,cnt++; i--;t=2;}prin tf("%d %d",cnt,sum);return 0;#i nclude<stdio.h>#in clude<math.h> int main(){int a=1;double b=1,pi=0,c=1;while(fabs(c)>=1e-6)pi=pi+c,b=b+2,a=-a,c=a/b; pi=pi*4; prin tf("%lf\n",pi); return 0;}}#i nclude<stdio.h>int main(){int a仁1,a2=1,n=2,sum=2,t; while(sum<=100){t=a1;a仁a2;a2=t+2*a2; sum=sum+a2;n++;}prin tf("%d\n", n-1);while(sum<=1000){t=a1;a仁a2;a2=t+2*a2; sum=sum+a2;n++;}prin tf("%d\n", n-1);while(sum<=10000){t=a1;a仁a2;a2=t+2*a2;}sum=sum+a2; n++;}prin tf("%d\n", n-1);}File Name :T01 Sxpp最次方数输出为整型.#i nclude<stdio.h>int main(){int x,a,s, n=1;scanf("%d %d",&x,&a);s=x;if(a!=O){for(; n<a;n++){s=s*x;if(s>=1000) s=s/100%10*100+s/10%10*10+s%10;}}prin tf("%d\n",s);return 0;輸出连腹奇蒙之和,格式如sa mple outputB示.#i nclude<stdio.h>int main(){int m, n,s;scan f("%d",&n);s=n*n*n;prin tf("%d*%d*%d=%d=" ,n,n,n ,s);for(m=1;s!=n*m;m++);if(n %2==1){for(s=-n/2;s< n/2;s++)pri ntf("%d+",m+2*s);prin tf("%d",m+n/2*2);}else{for(s=-n/2;s< n/2-1;s++)pri ntf("%d+",m+s*2+1); prin tf("%d",m+( n/2-1)*2+1);}}#i nclude<stdio.h>int main(){char a,b,c,x,y, z; a='A',b='B',c=C,x='X',y='Y',z='Z'; prin tf("%c=%c\n",a,z);prin tf("%c=%c\n",b,x);prin tf("%c=%c\n",c,y); return 0;}#i nclude<stdio.h>int main(){int a,b,t;sca nf("%d %d",&a,&b); if(a>b)t=a,a=b,b=t;for(;a<b;a++){ for(t=2;t<a;t++)if(a%t==0) break; if(t==a)pri ntf("%d ",a); }return 0;}#i nclude<stdio.h>int main(){int n=1;double a1= 1,a2=2,a3,sum=2; while( n<=19){a3=a1+a2;sum=sum+a3/a2;a仁a2;a2=a3;n++;}prin tf("%lf\n",sum);return 0;}}Input#i nclude<stdio.h>#in clude<math.h> int main() {double a;int n=0;sca nf("%lf",&a); a=fabs(a); if(a<=1)pri ntf("0\n"); else{while(a>1){ a=a/10;n++;}prin tf("%d\n", n);}#i nclude<stdio.h>int main(){int a=1,b=0,t, m,n=0; sca nf("%d", &t); while( n< t){ m=b; b=3*a+2*b;a=m;n++;}prin tf("%d %d",a,b); return 0;}}输出旅苣方法的数目#i nclude<stdio.h>#in clude<math.h> int main(){int n;int f(i nt n);sca nf("%d",&n);prin tf("%d\n",f( n));}int f(i nt n){int a;if(n==1|| n==2)a=0;else if(n==3)a=1;else if(n==4)a=3;elsea=f( n-1)*2+pow(2, n-4)-f( n-4); return a; }#i nclude<stdio.h>int main(){int n ,x=1234,y=1,a,b,c,d,e,f,g,h,i,j;sca nf("%d",&n);for(;x<49383&&y<98765;x++){y=x* n;a=x/10000%10; b=x/1000%10;c=x/100%10; d=x/10%10;e=x%10;f=y/10000%10; g=y/1000%10;h=y/100%10;i=y/10%10;j=y%10; if(a==b||a==c||a==d||a==e||a==f||a==g||a==h||a==i||a==j) con ti nue;if(b==c||b==d||b==e||b==f||b==g||b==h||b==i||b==j) con ti nue;if(c==d||c==e||c==f||c==g||c==h||c==i||c==j) con ti nue;if(d==e||d==f||d==g||d==h||d==i||d==j) con ti nue; if(e==f||e==g||e==h||e==i||e==j) con ti nue; if(f==g||f==h||f==i||f==j) con ti nue;if(g==h||g==i||g==j) continue;if(h==i||h==j) continue;if(i==j) continue;prin tf("%05d/%05d=%d\n",y,x, n); }return 0;}1 1 1/+(科十iy + +歹輪出计算绪果,赧鈕5粒小薮.#i nclude<stdio.h>#i nclude<stdlib.h>#in clude<math.h> int main(){in t m,n ,i;double x,s=0;sca nf("%d%d",&n,&m);for(i=n ;i<=m;i++){x=pow(i,2.0); s=s+1/x;}prin tf("%.5lf\n",s); return 0;}#i nclude<stdio.h>int main(){int x,y,a,b,L;double t;scan f("%d%d%d%d%d", &x, &y,&a,&b,&L); if(a==b) prin tf("impossible\n");else if(x>y){ if(a>b)y=L-x+y,t=(double)y/(a-b); else y=x-y,t=(double)y/(b-a);if((i nt)t==t)pri ntf("%d\n",(i nt)t); else prin tf("%lf\n",t);}else { if(a>b)y=y-x,t=(double)y/(a-b); else y=L-y+x,t=(double)y/(b-a); if((i nt)t==t)pri ntf("%d\n",(i nt)t); else prin tf("%lf\n",t);}return 0;}#i nclude<stdio.h>int _max(i nt a,i nt b){ _retur n a>b?a:b;}int a[20];int f[20][20];int main(){int n ,i,j,s=0;sca nf("%d",&n);for(i=0;i< n;i++)scan f("%d",&a[i]);for(j=1;j< n;j++)f[0][0]=a[0],f[0][j]=f[0][j-1]*a[j]; for(i=1;i< n;i++){f[i][i-1]=1;for(j=i;j< n;j++)f[i][j]=f[i][j-1]*a[j];}for(i=0;i< n;i++) for(j=i;j< n;j++) s=_max(s,f[i][j]);if(s==O)pri ntf("-1\n"); else prin tf("%d\n",s); return 0;}#i nclude<stdio.h>int main(){int x=192,y, z,a,b,c,d,e,f,g,h,i;for(;x<328;x++){y=2*x;z=3*x;a=x/100%10;b=x/10%10;c=x%10;d=y/100%10;e=y/10%10;f=y%10;g=z/100%10;h=z/10%10;i=z%10;if(a==b||a==c||a==d||a==e||a==f||a==g||a==h||a==i||a==0) con ti nue;if(b==c||b==d||b==e||b==f||b==g||b==h||b==i||b==0) con ti nue;if(c==d||c==e||c==f||c==g||c==h||c==i||c==0) con ti nue;if(d==e||d==f||d==g||d==h||d==i||d==0) con ti nue;if(e==f||e==g||e==h||e==i||e==O) con ti nue; if(f==g||f==h||f==i||f==O) con ti nue; if(g==h||g==i||g==O) con ti nue; if(h==i||h==O) continue;prin tf("%d %d %d\n",x,y,z);}return 0;}#i nclude<stdio.h>int main(){int a,b,c,sum=10;sca nf("%d%d%d",&a,&b,&c);for(;sum<=100;sum++){if(sum%3==a&&sum%5==b&&sum%7==c){ prin tf("%d\n",sum); break;}}if(sum==101)pri ntf("-1\n");return 0;}輸出合敎世圮起始导殆束年檢,用空恪隔开#i nclude<stdio.h>#in clude<math.h>int main(){int ce,y,m, n,a=0;sca nf("%d",&n); for(ce=0;;ce+=100){for(y=ce+1;y<ce+100;y+=2){ for(m=3;m<sqrt(y);m+=2){ if(y%m==0) break;}if(m>=sqrt(y)) break;}if(y==ce+101) a++;if(a==n) break;}prin tf("%d %d\n",ce,ce+99); return 0;}{int n,i;sca nf("%d",&n);for(i=1;i<=n ;i++){if(i%7==0) pri ntf("%d ",i);else if(i/1000%10==7||i/100%10==7||i/10%10==7||i%10==7) printf("%d ",i ); }return 0;}#i nclude<stdio.h>double a[100000000];int main(){int n,i;double ave,sum=0;sca nf("%d",&n);for(i=0;i< n;i++){scan f("%lf",&a[i]); sum=sum+a[i];}ave=su m/n;for(i=0,sum=0;i <n ;i++) sum=sum+(a[i]-ave)*(a[i]-ave); prin tf("%lf\n",sum); return 0;}int f[100000000];int main(){int n,i;sca nf("%d",&n);for(i=0;i< n;i++){int a,b;scan f("%d%d",&a,&b);f[i]=a+b;}for(i=0;i< n;i++){if(f[i]>100) f[i]=f[i]/10%10*10+f[i]%10,pri ntf("%d\n",f[i]); else prin tf("%d\n",f[i]); }return 0;}ttinc-udeAsfdio.hvttinc-udeAmafh.hvinfn H n v v k t八「efumn QO —k八inf main。
西工大C语言POJ习题答案之欧阳理创编
一.1.第一季10题全(注:第五题问题已经解决,确认AC!)#include <stdio.h>int main(){int a,b,sum;scanf("%d%d",&a,&b);sum=a+b;printf("%d\n",sum);return 0;}2.#include <stdio.h>#define PI 3.1415926int main(){double r,h,l,s,sq,vq,vz;scanf("%lf%lf",&r,&h);l=2*PI*r;s=PI*r*r;sq=4*PI*r*r;vq=4*PI*r*r*r/3;vz=s*h;printf("%.2lf\n%.2lf\n%.2lf\n%.2lf\n%.2lf\n",l,s,sq,vq,vz); return 0;}3.#include <stdio.h>int main(){int a,b,c;double d,e;scanf("%d%d%d",&a,&b,&c); d=a+b+c;e=d/3;printf("%lf\n%lf\n",d,e);return 0;}4.#include <stdio.h>int main(){int a,b,c;scanf("%d%d%d",&a,&b,&c); if(a<b)a=b;if(a<c)a=c;printf("%d\n",a);return 0;}5.#include<stdio.h>int main(){int i=0,j=0,k=1;char a[6];while((a[i]=getchar())!='\n') { i++;}for(;i>0;i--){if(a[j]==a[i-1]){j++;continue;}else {k=0;break;}}if(k==1)printf("yes\n");elseprintf("no\n");}6.#include<stdio.h>int main(){double a,c;scanf("%lf",&a);switch((int)a/10){case 0:c=a*0.1;break;case 1:c=(a-10)*0.075+10*0.1;break;case 2:case 3:c=(a-20)*0.05+10*0.075+10*0.1;break; case 4: case 5:c=(a-40)*0.03+20*0.05+10*0.075+10*0.1;break;case 6:case 7:case 8:case 9:c=(a-60)*0.015+20*0.03+20*0.05+10*0.075+10*0.1;break;default:c=(a-100)*0.01+40*0.015+20*0.03+20*0.05+10*0.075+10*0.1; }printf("%lf\n",c);return 0;}7.#include<stdio.h>int main(){double a,b,c;scanf("%lf",&a);c=(int)a;if(a>c)a=c+1;if(a>15)b=(a-15)*2.1+7+13*1.5;else {if(a>2)b=(a-2)*1.5+7;else b=7; }printf("%lf\n",b);return 0;}8.#include <stdio.h>int main(){int a,b,c,e,f=30,g=31,n;scanf("%d-%d-%d",&a,&b,&c);if((a%400==0)||(a%100!=0&&a%4==0)) e=29;elsee=28;switch (b){case 1:n=c;break;case 2:n=g+c;break;case 3:n=g+e+c;break; case 4:n=g+e+g+c;break; case 5:n=g+e+g+f+c;break;case 6:n=g+e+g+f+g+c;break;case 7:n=g+e+g+f+g+f+c;break;case 8:n=g+e+g+f+g+f+g+c;break;case 9:n=g+e+g+f+g+f+g+g+c;break;case 10:n=g+e+g+f+g+f+g+g+f+c;break;case 11:n=g+e+g+f+g+f+g+g+f+g+c;break;default: n=g+e+g+f+g+f+g+g+f+g+f+c;}printf("%d\n",n);return 0;}9.#include <stdio.h>int main(){int x;scanf("%d",&x);if(x>=90&&x<=100) printf("A\n");else if (x>=80)printf("B\n");else if (x>=70)printf("C\n");else if (x>=60)printf("D\n");elseprintf("E\n");return 0;}10.#include<stdio.h>int main(){double x,y,s;scanf("%lf,%lf",&x,&y);s=(x+2)*(x+2)+(y-2)*(y-2);if(s>1){s=(x+2)*(x+2)+(y+2)*(y+2);if(s>1){ s=(x-2)*(x-2)+(y+2)*(y+2); if(s>1){s=(x-2)*(x-2)+(y-2)*(y-2);if(s>1){printf("0\n");return 1;}}}}printf("10\n");return 0;}二。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
西北工业大学POJ答案绝对是史上最全版(不止100题哦……按首字母排序)1.“1“的传奇2.A+B3.A+BⅡ4.AB5.ACKERMAN6.Arithmetic Progressions7.Bee8.Checksum algorithm9.Coin Test10.Dexter need help11.Double12.Easy problem13.Favorite number14.Graveyard15.Hailstone16.Hanoi Ⅱ17.Houseboat18.Music Composer19.Redistribute wealth20.Road trip21.Scoring22.Specialized Numbers23.Sticks24.Sum of Consecutive25.Symmetric Sort26.The Clock27.The Ratio of gainers to losers28.VOL大学乒乓球比赛29.毕业设计论文打印30.边沿与芯的差31.不会吧,又是A+B32.不屈的小蜗33.操场训练34.插入链表节点35.插入排序36.插入字符37.成绩表计算38.成绩转换39.出租车费40.除法41.创建与遍历职工链表42.大数乘法43.大数除法44.大数加法45.单词频次46.迭代求根47.多项式的猜想48.二分查找49.二分求根50.发工资的日子51.方差52.分离单词53.分数拆分54.分数化小数55.分数加减法56.复数57.高低交换58.公园喷水器59.信点兵60.行程编码压缩算法61.合并字符串62.猴子分桃63.火车站64.获取指定二进制位65.积分计算66.级数和67.计算A+B68.计算PI69.计算π70.计算成绩71.计算完全数72.检测位图长宽73.检查图像文件格式74.奖金发放75.阶乘合计76.解不等式77.精确幂乘78.恐怖水母79.快速排序80.粒子裂变81.链表动态增长或缩短82.链表节点删除83.两个整数之间所有的素数84.路痴85.冒泡排序86.你会存钱吗87.逆序整数88.排列89.排列分析90.平均值函数91.奇特的分数数列92.求建筑高度93.区间素数94.三点顺序95.山迪的麻烦96.删除字符97.是该年的第几天98.是该年的第几天?99.数据加密100.搜索字符101.所有素数102.探索合数世纪103.特殊要求的字符串104.特殊整数105.完全数106.王的对抗107.危险的组合108.文件比较109.文章统计110.五猴分桃111.小型数据库112.幸运儿113.幸运数字”7“114.选择排序115.寻找规律116.循环移位117.延伸的卡片118.羊羊聚会119.一维数组”赋值“120.一维数组”加法“121.勇闯天涯122.右上角123.右下角124.圆及圆球等的相关计算125.圆及圆球等相关计算126.程序员添加行号127.找出数字128.找幸运数129.找最大数130.整数位数131.重组字符串132.子序列的和133.子字符串替换134.自然数立方的乐趣135.字符串比较136.字符串复制137.字符串加密编码138.字符串逆序139.字符串排序140.字符串替换141.字符串左中右142.组合数143.最次方数144.最大乘积145.最大整数146.最小整数147.最长回文子串148.左上角149.左下角1.“1“的传奇#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){int n,i,j,k=0,x=1,y,z,m,p,q,a,s=0;scanf("%d",&n);m=n;for(i=1;i<12;i++){m=m/10;k++;if(m==0)break;}q=n;k=k-1;for(a=1;a<=k;a++){x=x*10;}y=q%x;z=q/x;p=q-y;if(z>=2)s=s+x+z*k*(x/10); elses=s+z*k*(x/10);for(j=p;j<=n;j++) {m=j;for(i=1;i<12;i++){x=m%10;if(x==1)s++;m=m/10;if(m==0)break;}}printf("%d",s);return 0;}2.A+B#include <stdio.h>int doubi(int n,int m){n=n+m;n=n%100;return n;}int main(){int t,i,a[100],n,m;scanf("%d",&t);for (i=0;i<=(t-1);i++){scanf("%d%d",&n,&m);a[i]=doubi(n,m);}for (i=0;i<=(t-1);i++)printf("%d\n",a[i]);return 0;}3.A+BⅡ#include <stdio.h>int main(){int A,B,sum;scanf("%d%d",&A,&B);sum=A+B;printf("%d\n",sum);return 0;}4.AB#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){char s[100],q[100];double a,b,c;int n=0,i;scanf("%lf%lf",&a,&b);c=a*b;sprintf(s,"%.0lf",c);for(i=0;i<strlen(s);i++){n=n+s[i]-48;}while(n>=10){sprintf(q,"%d",n);n=0;for(i=0;i<strlen(q);i++)n=n+q[i]-48;}printf("%d",n);return 0;}5.ACKERMAN#include <stdio.h>#include <stdlib.h>int ack(int x,int y){int n;if (x==0) {n=y+1;return n;}else if (y==0) n=ack(x-1,1);else n=ack(x-1,ack(x,y-1));return n;}int main(){int m,b;scanf("%d%d",&m,&b);m=ack(m,b);printf("%d",m);return 0;}6.Arithmetic Progressions#include <stdio.h>#include <math.h>int g(int n){int i;if(n==1) return 0;if(n==2) return 1;if(n==3) return 1;for(i=2;i<=sqrt(n);i++) if(n%i==0) return 0;return 1;}int f(int a,int b,int c){int i=0,s=a-b;if(c==1&&g(a)==1) return a;if(b==0&&g(a)!=1) return -1;while(1){s=s+b;if(g(s)) i++;if(i>=c) break;}return s;int main(){int a,b,c,d[100],i=0,n;while(1){scanf("%d%d%d",&a,&b,&c);if(a==0&&b==0&&c==0) break;d[i]=f(a,b,c);i++;}n=i;for(i=0;i<n;i++)printf("%d\n",d[i]);return 0;}7.Bee#include <stdio.h>#include <stdlib.h>int main()int A[100],i=0,j,k,female=0,male=1,x;for(;;i++){scanf("%d",&A[i]);if(A[i]==-1)break;}for(j=0;j<i;j++){female=0,male=1;for(k=1;k<A[j];k++){x=female;female=male;male=x+male+1;}printf("%d %d\n",male,female+male+1);}return 0;}8.Checksum algorithm #include <stdio.h>#include <stdlib.h>#include <string.h>int main(){int i,n,t,j;char s[100][100];for(i=0;;i++){gets(s[i]);if(s[i][0]=='#') break;}n=i;for(i=0;i<n;i++){t=0;for(j=0;j<strlen(s[i]);j++)if(s[i][j]==32) t=t;else t=t+(j+1)*(s[i][j]-64);printf("%d\n",t);}return 0;}9.Coin Test#include <stdio.h>#include <stdlib.h>int main(){char A[100000];int n,i=0,a=0,b=0,j;double x;while(1){scanf("%c",&A[i]);if(A[i]=='\n')break;i++;}for(j=0;j<i;j++){if(A[j]=='S'){printf("WA");goto OH;}if(A[j]=='U')a++;if(A[j]=='D')b++;}x=a*1.0/(a+b)*1.0;if(x-0.5>0.003||x-0.5<-0.003) printf("Fail");elseprintf("%d/%d",a,a+b);OH:return 0;}10.Dexter need help#include <stdio.h>int fun(int a){if(a==1) return 1;elsereturn fun(a/2)+1;}int main(){int a,b[100],i=0,j; while(1){scanf("%d",&a);if(a==0)break;b[i]=fun(a);i++;}for(j=0;j<i;j++){printf("%d\n",b[j]); }return 0;}11.Double#include <stdio.h>#include <stdlib.h>int main(){int a[100],b[100],i,j,n,t=0;for(i=0;;i++){scanf("%d",&a[i]);if(a[i]==0) break;}n=i;for(i=0;i<n;i++)b[i]=2*a[i];for(i=0;i<n;i++)for(j=0;j<n;j++)if(a[i]==b[j]) t++;printf("%d",t);return 0;}12.Easy problem#include <stdio.h>#include <math.h>int main(){int N,i,n,j=0;scanf("%d",&N);for(i=2;i<N+1;i++){if((N+1)%i==0)j++;}printf("%d",j/2);return 0;}13.Favorite number #include <stdio.h>#include <string.h>#define MAXNUM 100000int prime_number = 0;int prime_list[MAXNUM]; bool is_prime[MAXNUM]; int ans[MAXNUM + 2];int dp[MAXNUM + 2];void set_prime() {int i, j;memset(is_prime, 0, sizeof(is_prime));for (i = 2; i < MAXNUM; i++) {if (is_prime[i] == 0) {prime_list[prime_number++] = i;if (i >= MAXNUM / i) continue;for (j = i * i; j < MAXNUM; j+=i) {is_prime[j] = 1;}}}}int main() {int i, j, k,o=0,d[100];memset(dp, -1, sizeof(dp));set_prime();ans[0] = 0;dp[1] = 0;for (i = 1; i <= MAXNUM; i++) {ans[i] = ans[i - 1] + dp[i];if (dp[i + 1] == -1 || dp[i + 1] > dp[i] + 1) { dp[i + 1] = dp[i] + 1;}for (j = 0; j < prime_number; j++) {if (i > MAXNUM / prime_list[j]) break;k = i * prime_list[j];if (dp[k] == -1 || dp[k] > dp[i] + 1) {dp[k] = dp[i] + 1;}}}while (scanf("%d%d", &i, &j) == 2 && (i || j)) { d[o]=ans[j] - ans[i - 1];o++;}for(i=0;i<o;i++)printf("%d\n",d[i]);}14.Graveyard#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){int a[100],b[100],n,i,j;double s,p,l,t;for(i=0;;i++){scanf("%d%d",&a[i],&b[i]);if(a[i]==0&&b[i]==0) break;}n=i;for(i=0;i<n;i++){p=10000;if(b[i]%a[i]==0){printf("0.0000\n");continue;};t=10000/((double)a[i]);for(j=1;j<a[i]+b[i];j++){l=10000/((double)(a[i]+b[i]));l=t-j*l;l=fabs(l);if(l<p) p=l;}s=(a[i]-1)*p;printf("%.4lf\n",s);}return 0;}15.Hailstone#include <stdio.h>#include <stdlib.h>#include <string.h>int f(int n){int s=1;while(1){if(n==1) return s;else if(n%2==0) n=n/2,s++;else n=3*n+1,s++;}}int main()int n,m,i,j=0,t;scanf("%d%d",&m,&n);printf("%d %d",m,n);if(m>n) t=m,m=n,n=t;for(i=m;i<=n;i++)if(f(i)>j) j=f(i);printf(" %d",j);return 0;}16.Hanoi Ⅱ#include <stdio.h>#include <stdlib.h>#define M 70int start[M], targe[M];long long f(int *p, int k, int fina){if(k==0) return 0;if(p[k]==fina) return f(p,k-1,fina); return f(p,k-1,6-fina-p[k])+(1LL<<(k-1));int main (){long long ans;int n;while(scanf("%d",&n),n){int i;for(i=1;i<=n;i++) scanf("%d",&start[i]);for(i=1;i<=n;i++) scanf("%d",&targe[i]);int c=n;for(;c>=1&&start[c]==targe[c];c--);if(c==0){printf("0\n"); continue;}int other=6-start[c]-targe[c];ans=f(start,c-1,other)+f(targe,c-1,other)+1;printf("%lld\n",ans);}return 0;}17.Houseboat#include <stdio.h>#include <stdlib.h>#include <math.h>#define pi 3.1415926int f(float x,float y){int i;for(i=0;;i++)if(50*i>sqrt(x*x+y*y)*sqrt(x*x+y*y)*pi/2) break;return i;}int main(){int n,i,a[100];float x,y;scanf("%d",&n);for(i=0;i<n;i++){scanf("%f%f",&x,&y);a[i]=f(x,y);}for(i=0;i<n;i++)printf("%d %d\n",i+1,a[i]);return 0;}18.Music Composer19.Redistribute wealth#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){int a[1000],b[1000],n,i,j,s,sum,t,m,mid,c[100],k=0;while(1){scanf("%d",&n);if(n==0) break;{s=0;for(i=1;i<=n;i++){scanf("%d",&a[i]);s=s+a[i];}m=s/n;b[1]=a[1]-m;b[0]=0;for(i=2;i<n;++i)b[i]=b[i-1]+a[i]-m;for(i=0;i<n;i++)for(j=0;j<n-1-i;j++)if(b[j]>b[j+1])t=b[j],b[j]=b[j+1],b[j+1]=t;mid=b[n/2];sum=0;for(i=0;i<=n-1;++i) sum=sum+fabs(mid-b[i]);c[k]=sum;k++;}}for(i=0;i<k;i++) printf("%d\n",c[i]);return 0;}20.Road trip#include <stdio.h>#include <stdlib.h>#include <math.h>int f(int n){int a[100],b[100],i,s;for(i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);s=a[0]*b[0];for(i=1;i<n;i++)s=s+a[i]*(b[i]-b[i-1]);return s;}int main(){int n,c[100],i=0;while(1){scanf("%d",&n);if(n==-1) break;c[i]=f(n);i++;}n=i;for(i=0;i<n;i++)printf("%d\n",c[i]);return 0;}21.Scoring#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){int i,j,sum,min,c,count,n,a,b;char s1[50],s2[50];scanf("%d",&n);for(i=0;i<n;i++){count=sum=0;scanf("%s",s2);for(j=0;j<4;j++){scanf("%d%d",&a,&b);if(b!=0){sum+=(a-1)*20+b;count++;}}if(i==0){c=count,min=sum;strcpy(s1,s2);}else if(count>c||(count==c&&sum<min)){min=sum;c=count;strcpy(s1,s2);}}printf("%s %d %d\n",s1,c,min);return 0;}22.Specialized Numbers#include <stdio.h>#include <stdlib.h>int main(){int i,n,sum10,sum12,sum16;for(i=2992;i<3000;i++){n=i;sum10=0;while(n){sum10+=n%10;n/=10;}n=i;sum12=0;while(n){sum12+=n%12;n/=12;}n=i;sum16=0;while(n){sum16+=n%16;n/=16;}if(sum10==sum12&&sum12==sum16) printf("%d\n",i);}return 0;}23.Sticks#include <stdio.h>#include <string.h>#include <stdlib.h>int len[64], n, minlen, get;bool b[64];int cmp(const void *a, const void *b){return *(int *)a < *(int *)b ? 1 : -1;}bool dfs(int nowlen, int nowget, intt){if(cnt >= n) return false;if(get == nowget) return true;int i;bool f = false;if(nowlen == 0) f = true;for(i =t; i < n; i++){if(!b[i]){if(len[i] + nowlen == minlen){b[i] = true;if(dfs(0, nowget+1, nowget))return true;b[i] = false;return false;}else if(len[i] + nowlen < minlen){b[i] = true;if(dfs(nowlen+len[i], nowget, i+1))return true;b[i] = false;if(f) return false;while(i + 1 < n && len[i] == len[i+1]) i++;}}}return false;}int main(){int i, tollen;while(scanf("%d", &n), n){tollen = 0;int j = 0, p;for(i = 0; i < n; i++){scanf("%d", &p);if(p <= 50){len[j] = p;tollen += len[j];j++;}}n = j;if(n == 0){printf("0\n");continue;}qsort(len, n, sizeof(int), cmp);for(minlen = len[0]; ; minlen++) {if(tollen % minlen) continue;memset(b, 0, sizeof(b));get = tollen / minlen;if(dfs(0, 0, 0)){printf("%d\n", minlen);break;}}}return 0;}24.Sum of Consecutive#include <stdio.h>#include <stdlib.h>#include <string.h>int len[64],n,minlen,get;int b[64];int cmp(const void *a,const void *b) {return *(int *)a<*(int *)b?1:-1;}int dfs(int nowlen,int nowget,intt){if(cnt>=n) return 0;if(get==nowget) return 1;int i,f=0;if(nowlen==0) f=1;for(i=cnt;i<n;i++){if(len[i]+nowlen==minlen){b[i]=1;if(dfs(0,nowget+1,nowget)) return 1;b[i]=0;return 0;}else if(len[i]+nowlen<minlen){b[i]=1;if(dfs(nowlen+len[i],nowget,i+1)) return 1;b[i]=0;if(f) return 0;while(i+1<n&&len[i]==len[i+1]) i++;}}return 0;}int main(){int i,tollen,q=0,c[100];while(scanf("%d",&n),n){tollen=0;int j=0,p;for(i=0;i<n;i++){scanf("%d",&p);if(p<=50){len[j]=p;tollen+=len[j];j++;}}n=j;if(n==0){printf("0\n");continue;}qsort(len,n,sizeof(int),cmp);for(minlen=len[0];;minlen++){if(tollen%minlen) continue;memset(b,0,sizeof(b));get=tollen/minlen;if(dfs(0,0,0)){c[q]=minlen;q++;break;}}}for(i=0;i<q;i++)printf("%d\n",c[i]);return 0;}25.Symmetric Sort#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){double A[100];int i=0,j=0,k=0,l=0,sum=0;while(1){scanf("%lf",&A[i]);if(A[i]==0)break;i++;}for(j=0;j<i;j++){if(A[j]==2)printf("1\n");else{int B[10000],m=1,number=0;double n;B[0]=2;for(k=3;k<=A[j];k+=2){n=(double)k;for(l=2;l<=sqrt(n);l++){if(k%l==0)goto ai;}B[m]=k;m++;ai:;}for(k=0;k<m;k++){sum=0;for(l=k;l<m;l++){sum+=B[l];if(sum==A[j]){number++;break;}}}printf("%d\n",number);}}return 0;}26.The Clock#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){char s[100][100],a[100];int i,j,n;scanf("%d",&n);for(i=0;i<n;i++) scanf("%s",s[i]);for(i=0;i<n-1;i++)for(j=0;j<n-1-i;j++)if(strlen(s[i])>strlen(s[i+1])) strcpy(a,s[i]),strcpy(s[i],s[i+1]),strcpy(s[i+1],a);if(n%2==0){for(i=0;i<n-1;i=i+2) printf("%s ",s[i]);printf("%s ",s[n-1]);for(i=i-3;i>0;i=i-2) printf("%s ",s[i]);}else{for(i=0;i<n-1;i=i+2) printf("%s ",s[i]);printf("%s ",s[n-1]);for(i=i-1;i>0;i=i-2) printf("%s ",s[i]);}return 0;}27.The Ratio of gainers to losers #include<stdio.h>int main(){char s[5];int i,sum=0;gets(s);for(i=0;s[i]!='\0';i++){switch(s[i]){case'I': sum+=1;break; case'V': sum=5-sum;break; case'X':sum=10-sum;break; }}printf("%d\n",sum);return 0;}28.VOL大学乒乓球比赛#include <stdio.h>#include <stdlib.h>int main(){printf("A=Z\nB=X\nC=Y\n");return 0;}29.毕业设计论文打印#include <stdio.h>#include <stdlib.h>int main(){int a[100],j=1,i,n,m;scanf("%d%d",&n,&m);for(i=0;i<n;i++)scanf("%d",&a[i]);for(i=0;i<n;i++)if(a[i]>a[m]) j++;printf("%d",j++);return 0;}30.边沿与芯的差#include <stdio.h>#include <stdlib.h>int main(){int A[100][100],i,j,m,n,s=0,t=0;scanf("%d%d",&n,&m);for(i=1;i<=n;i++){for(j=1;j<=m;j++){scanf("%d",&A[i][j]);}}for(i=2;i<m;i++)s=s+A[1][i];for(i=2;i<m;i++)。