1. Taxi Pricing
#include <stdio.h>#include<math.h>intMain () {Doubles,m; intm1=0, m2=0; intt=0, n=0; printf ("Please enter mileage s=%d\n"); printf ("Please enter the waiting time t=%d\n"); scanf ("%d", s); scanf ("%d", T); if(s<=3) printf ("%d", m1=Ten); Else if(s>=3&&s<=Ten) printf ("%d", m1=Ten+2* (S-3)); Else{printf ("%d", m1= (S-Ten)*3+ (S-3)*2+Ten);} if(t<5) {m2=0; } Else{ intm2=t/5+0.5; } m=m1+m2; printf ("Total fare =%d", M); scanf ("%d",&m); return 0; }
2.3 Numbers
#include <stdio.h>intMain () {intA,b,c,n; printf ("Please enter three numbers separated by a space \ n"); scanf (" %d%d%d",&a,&b,&c); if(a>b) {n=A; A=b; b=N; } if(a>c) {n=A; A=B; C=N; } if(b>c) {n=b; b=B; C=N; } printf (" %d%d%d", A,b,c); return 0; }
3. Student Achievement
#include <stdio.h>intMain () {Chargrade; printf ("Enter level five score: \ n"); scanf ("%c",&grade); Switch(grade) { Case'A': printf ("90~100\n"); Break; Case'B': printf ("80~89\n"); Break; Case'C': printf ("70~79\n"); Break; Case'D': printf ("60~69\n"); Break; Case'E': printf ("0~59\n"); Break; default: printf ("fault\n"); Break; } return 0;}
4. Triangles
#include <stdio.h>int main () { int I,j; for (J=1 ; J<=10 ; J++ for (I=1 ; I<=j;i++) printf ( * ); printf ( \n " ); return 0 ;}
5. Expressway speeding penalty (not very clear)
#include <stdio.h>intMain () {Doublen,m,b; printf ("Please enter the speed limit and the actual speed, separated by a space:"); scanf ("%LF%LF",&n,&m); if(m>n&&m<b)DoubleB= (Double) (N-M) * -/m; if(b>Ten) { if(b>Ten&&b< -) printf ("A fine of $200"); Else if(b> -) printf ("revoke a driver's license"); } Elseprintf ("not to be punished"); return 0; }
The fifth triangle in the book does not judge. It's so hard.
C Language Fifth time assignment