2016 1-4

    科技2024-11-08  7

    //2016 1-4 //1、 #include<stdio.h> #define m 10 int main(){ int x=0,zero=0,y=0; for(int i=0;i<m;i++) { int w; scanf("%d",&w); if(w>0) y++; else if(w<0) x++; else zero++; printf("%d %d %d\n",x,zero,y); } } 2、 #include<stdio.h> #include<math.h> int isflag(int n) { for(int i=2;i<=sqrt(n);i++) if(n%i==0) return 0; return 1; } int main() { for(int i=10;i<100;i++) if(isflag(i)) { int x=i/10+(i%10)*10; if(isflag(x)) printf("%d\n",x); } } 3、 #include<stdio.h> int main(int argc, char const *argv[]) { printf("请输入 总额: 类型:(1/2) 年限: \n"); int x; int y; int z; double rate; scanf("%d %d %d",&x,&y,&z); if(y==1) { if(z>=1&&z<=5) rate=2.75*0.01; else if(z>5&&z<=30) rate=3.25*0.01; else { printf("输入数据有误\n"); return 0; } } else if(y==2) { if(z==1) rate=4.35*0.01; else if(z>=2&&z<=5) rate=4.75*0.01; else if(z>5&&z<=30) rate=4.9*0.01; else { printf("输入数据有误\n"); return 0; } } else { printf("输入数据有误\n"); return 0; } double fixed=x*1.0/z/12; double sum; double SUM=0; for(int i=1;i<=z*12;i++) { sum=fixed+(x-fixed*(i-1))*rate; SUM+=sum; printf("第%d个月还款%lf\n",i,sum); } printf("总还款%lf\n",SUM); } //分模块写会好一些吧 //4、 #include<stdlib.h> #include<stdio.h> struct stu{ int x; double scorex; int y; double scorey; int z; double scorez; int w; double scorew; int sumcredit; double avescore; }student[40]; int cmp(const void *a,const void *b) { if((*(struct stu*)a).sumcredit!=(*(struct stu*)b).sumcredit) return (*(struct stu*)b).sumcredit-(*(struct stu*)a).sumcredit; else return (*(struct stu*)b).avescore-(*(struct stu*)a).avescore; } int main(int argc, char const *argv[]) { int no; for(int i=1;i<=3;i++) { double a,b,c,d; scanf("%d",&no); scanf("%lf %lf %lf %lf",&a,&b,&c,&d); if(a>60) student[no-1].x=5; else student[no-1].x=0; if(b>60) student[no-1].y=4; if(c>60) student[no-1].z=4; if(d>60) student[no-1].w=3; student[no-1].scorex=a; student[no-1].scorey=b; student[no-1].scorez=c; student[no-1].scorew=d; student[no-1].sumcredit=student[no-1].x+student[no-1].y+student[no-1].z+student[no-1].w; student[no-1].avescore=(a+b+c+d)/4; } qsort(student,3,sizeof(student[0]),cmp); for(int i=1;i<=36;i++) { printf("%d %lf\n",student[i-1].sumcredit,student[i-1].avescore ); } return 0; }

     

    Processed: 0.019, SQL: 8