首页 > 代码库 > 王重阳160809311第5次作业

王重阳160809311第5次作业

#include<stdio.h>//输入三个数有小到大排序 int main(){    int x;    int y;    int z;    printf("输入三个整数:");    scanf("%d %d %d",&x,&y,&z);    if(x<y && x<z)    {        if(y<z)        printf("按从小到大排序为:%d %d %d\n",x, y, z);        if(y>z)        printf("按从小到大排序为:%d %d %d\n",x, z, y);            }        if(y<x && y<z)    {        if(x<z)        printf("按从小到大排序为:%d %d %d\n",y, x, z);        if(x>z)        printf("按从小到大排序为:%d %d %d\n",y, z, x);            }            if(z<y && z<x)    {        if(y<x)        printf("按从小到大排序为:%d %d %d\n",z, y, x);        if(y>x)        printf("按从小到大排序为:%d %d %d\n",z, x, y);                      }      return 0;    }
#include<stdio.h>int main()//2.高速公路限速处罚{    int x,z;    scanf("%d %d",&x,&z);    double b = (double)(x-z)*100/z;    if (b>50)printf("超过限速 %.0f%%. 吊销执照",b);    if(b>=10&&b<=50)printf("超出限速 %.0f%%. 罚款 200",b);    if(b<10)printf("未超过限速");}int count(double x){//TODO:if (x<0) {cout<<"不可能"<<endl; return 0;}double t=0;if (x<3) {t=10;}else{t+=10;if (x>13) {t+=20+3*(x-13);}else{t+=2*(x-3);}}return int(t+0.5);}#include <stdio.h>int main()//4.五级制成绩分布 {    int i,A,B,C,D,E,n,s;    A=B=C=D=E=0;    printf("Enter n:");    scanf("%d",&n);    for(i=0;i<n;++i)    {        printf("Enter grade %d:",i+1);        scanf("%d",&s);        switch(s/10)        {        case 1:        case 2:        case 3:        case 4:        case 5:E++;break;        case 6:D++;break;        case 7:C++;break;        case 8:B++;break;        case 9:        case 10:A++;break;        }    }    printf("The number of A(90~100):%d\n",A);    printf("The number of B(80~89):%d\n",B);    printf("The number of C(70~79):%d\n",C);    printf("The number of D(60~69):%d\n",D);    printf("The number of E(0~59):%d\n",E);    return 0;}#include<stdio.h>#include<math.h>
#include <stdio.h>//三角形判断int main(){    int a,b,c;    printf("Please input the triangle 3 side length...\n");    scanf("%d%d%d",&a,&b,&c);    if(a+b<=c || a+c<=b || b+c<=a)        printf("Not a triangle!\n");    else if(a==b && b==c)        printf("A equileteral triangle!\n");    else if(a==b || b==c || a==c)        printf("A isosceles triangle!\n");    else if(a*a+b*b==c*c || a*a==b*b+c*c || a*a+c*c==b*b)        printf("A right triangle!\n");    else printf("Impossible\n");}

 

#include<stdio.h>int main()//6.双循环打印三角形 {    int i,j;    for(j=1;j<=10;j++)    {        for(i=1;i<=11-j;i++)        {            printf("*");        }        printf("\n");    }}
#include<stdio.h>int main()//出租车计价{     int s,time,rmb;     printf("请分别输入行驶里程(公里)和等待时间(分钟):");     scanf("%d %d",&s,&time);     if (time%5==0)     {         if(s<=0)         rmb=(time/5)*2;          else if (s<=3)           rmb=10+(time/5)*2;        else if(s<=10)           rmb=10+(s-3)*2+(time/5)*2;          else          rmb=10+(10-3)*2+(s-10)*3+(time/5)*2;     }     else      {        if (s<=0)           rmb=(time/5+1)*2;          else if (s<=3)        rmb=10+(time/5+1)*2;         else if(s<=10)           rmb=10+(s-3)*2+(time/5+1)*2;          else          rmb=10+(10-3)*2+(s-10)*3+(time/5+1)*2;     }    printf("乘客应付%d元\n",rmb);    return 0;}

 

王重阳160809311第5次作业