#include <stdio.h> int main() { int x=90; int y;//车速 printf("超速的车速:"); scanf("%d",&y); if(y>1.1*x && y<1.5*x) { printf("处罚200元"); } if(y>1.5*x) { printf("吊销执照"); }
#include<stdio.h> int main()//出租车计价 { int s,time,rmb; printf("请输入行驶总里程:"); scanf("%lf",&x); printf("请输入等待时间:"); scanf("%lf",&y); 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元 ",rmb); return 0; }
#include<stdio.h> int main () { int a,b,c,t; printf("输入3个数:"); scanf("%d %d %d",&a,&b,&c); if(a<b) { t=a;a=b;b=t; } if(a<c) { t=a;a=c;c=t; } if(b<c) { t=b;b=c;c=t; } printf("顺序是%d %d %d",a,b,c); return 0;
#include<stdio.h> int main() { int score,n,i; int a,b,c,d,e; a=b=c=d=e=0; printf("请输入学生个数: "); scanf("%d",&n); for(i=1;i<=n;i++) { printf("请输入第%d个学生成绩: ",i); scanf("%d",&score); if(score>=90) a++; else if(score>=80 && score<90) b++; else if(score>=70 && score<80) c++; else if(score>=60 && score<70) d++; else e++; } printf("A:%d人, B:%d人, C:%d人, D:%d人, E:%d人 ",a,b,c,d,e); return 0;
#include<stdio.h> int main() { int n=10,i,j; for(i=0;i<n;i++) { for(j=0;j<=i;j++) printf("*"); printf(" "); } }
#include <stdio.h> int main() { 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:E;break; case 2:D;break; case 3:C;break; case 4:B;break; case 5:A;break; } } printf("The number of A(90~100):%d ",A); printf("The number of B(80~89):%d ",B); printf("The number of C(70~79):%d ",C); printf("The number of D(60~69):%d ",D); printf("The number of E(0~59):%d ",E); return 0; }