y=
x (x<1)
2x-1 (1<=x<10)
3x-11 (x>=10)
xy
main ( )
{
int x,y;
scanf(" d",&x);
if (x<1)
{y=x;
printf(“x=%3d y=x=%d\n”,x,y)
}
else if (x<10)
{y=2*x-1;
printf(“x=%3d y=2*x-1 =%d\n”,x,y)
}
else
{y=3*x-11;
printf(“x=%3d y=3*x-11 =%d\n”,x,y)
}
}
1.4100
2.4400
5.13leapleap=1leap=0leap1()
5.13
main()
{
int year;
scanf("%d",&year);
if( year%4==0&&year%100!=0||year%4==0&&year%400==0 )
printf("\nIt is a leap year.\n");
else printf("\nIt is not a leap year.\n");
}
:
1989
1989 is not a leap year.
2000
2000 is a leap year.24
2
main()
{
int year,leap;
scanf("%d",&year);
if(year%4==0) 4
{if(year%100==0) 4100
{if(year%400==0) leap=1; 4100400
else leap=0;} 4100400
else leap=1;} 4100
else leap=0; 4
if(leap)printf("\nIt is a leap year.\n");
else printf("\nIt is not a leap year.\n");
}
3773,
1234
1234%10=
1234%100=
1234%1000=
1234/1000=
1234/100=
1234/10=
#include<stdio.h>
main()
{
int a,c1,c2,c3,c4
printf(“Input a number\n”);
scanf(“%d”,&a);
c1=a%10;
c2=a%100/10;
c3=a%1000/100;
c4=a/1000;
if(c1==c4&&c2==c3) printf(“HUIWEN NUMBER \n”);
else printf(“NO HUIWEN \n”);
}
ax2bxc=0
4.12
a=0
b2-4ac=0
b2-4ac0
b2-4ac0
N S(5.14)
#include<mathh>
main()
float abcddiscx1x2realpartimagpart
scanf("fff"&a&b&c)
printf("The equation")
if(fabs(a)=le-6)
printf("is not a quadratic")
else
{disc=b*b-4*a*c
if(fabs(disc)=le-6)
printf("has two equal roots:%8.4fn"-b(2*a))
else if(discle-6)
x1=(-bsqrt(disc))(2*a)
x2=(-b-sqrt(disc))(2*a)
printf("has distinct real roots:%8.4f and %8.4fn"x1x2);
else
realpart=-b(2*a)
imagpart=sqrt(-disc)(2*a)
printf("has comPlex roots n")
printf("%8.4f+%8.4fin"realpartimagpart)
printf("%8.4f-%8.4fin"realpartimagpart)
}
discb2-4acdiscb2-4ac0disc(b2-4ac)
if(disc==0)…… disc(fabs(disc))(10-6)disc=0realpartP
imagpartq
121
The equation has two equalroots -10000
122
The equation has complex roots
-1000010000i
-10000-10000i
261
The equation has distinct real roots:-0.1771
and =2.8229
5.7(S)
s250km
250≤S500 2
500≤S1000 5
1000≤S2000 8
2000≤S3000 10
3000≤S 15
P(Price)w(weight)Sd(discount)f(freight)f=P*w*S*(1-
d)5.15
250(250500100020003000)ccS/250c250c<1S<250
1≤c2250≤S<500d=22≤c4d=54≤c8d=88≤c12d=10
c≥12d=15
main()
int cS
float Pwdf
scanf("ffd"&P&w&S)
if(S=3000) c=12
elsec=S250
switch(c)
case0 d=0break
case1 d=2break
case2
case3 d=5break
case4
case5
case6
case7 d=8break
case8
case9
case10
case11 d=10break
case12 d=15break
f=P*w*S*(1-d1000)
printf("freight=154f"f)
10020300
freight= 588000.0000
cSc=S250S≥3000c=12cSSwitchcaseS≥3000
Main( )
{ int s;
float t,p,w;
printf(“shu ru ju li\n”);
scanf(“%d”,&s);
if(s>=3000) { t=p*s*w *0.85; printf(“%f\n”,t); }
else if(s>=2000) { t=p*s*w *0.9; printf(“%f\n”,t); }
else if(s>=1000) { t=p*s*w *0.92; printf(“%f\n”,t); }
else if(s>=500) { t=p*s*w *0.95; printf(“%f\n”,t); }
else if(s>=250) { t=p*s*w *0.98; printf(“%f\n”,t); }
else t=p*s*w ;
}