5.1
5.2
5.3if
5.4switch
5.5
5.1.1
C6
():
()
=()
()
=()
():
= = ()
!=()
5.1
1.
2.01
3.
1
2
cab c(ab)
ab==c (ab)==c
a=bc a=(bc) 5.1
5.2
(1) &&(AND)
(2) || ()
(3) ! (NT)
“&&” ||” ()
!” ()
1.01
2.
5>3&&8<4-!0
(5>3)&&(8<4-!0)
(1) a && b && c
(2) a||b||c
… …

C
if
5.3 if
if()
5.3.1 if
Cif
1,if
N
Y
2,if
1 2
Y N
1
2
if(a>60)
printf(“\n”
else
printf(“\n”);
a>60Y N
3,i f
……
1
N
1
Y 2
n
Y
Y
2 3 n
N
N
if(number>500) cost=0.15;
else if(number>300) cost=0.10;
else if(number>100) cost=0.075;
else if(number>50) cost=0.05;
else cost=0;
if
(1) ifif
if
if(3) printf(“k )
if(?a?)printf(“d” a?)
(2)
(3)
(4) else
(5)if{ }{ }
,”
,”
if
if
if( 1 11
else 12
else
if (2 21
else 22
0101112
0202122
if if
ifelse,,:
if( )
{ if () 1}
else
2
{ }if,elseif
ifelseelseif
int I=1;
if(I<=0) printf("****\n")
else printf("%%%%\n");
main()
{ int a=5,b=4,c=3,d=2;
if(a>b>c)
printf("%d\n",d);
else if((c-1>=d)==1)
printf("%d\n",d+1);
else
printf("%d\n",d+2);
}
( ),3
main()
{ int x;
scanf("%d",&x);
if(x--<5)
printf("%d",x);
else
printf("%d",x++);
}
5( )
:4
main()
{
int a=3,b=4,c=5,d=2;
if(a>b)
if(b>c)
printf("%d",d++ +1);
else
printf("%d",++d +1);
printf("%d\n",d);
}
( )
:2
A if(a)
printf("%d\n",x);
else
printf("%d\n",y)
B if(a==0)
printf("%d\n",y);
else
printf("%d\n",x)
C if (a!=0)
printf("%d\n",x);
else
printf("%d\n",y)
D if(a==0)
printf("%d\n",x);
else
printf("%d\n",y)26
123
123
if(a>b) max=a;
else max=b;
max=(a>b)?a:b;
cSwitch
switch()
case11
case22

casenn
default n1
switch
,=i,i,n+1
,default
Switch
Switch(grade)
case'a' printf("85100n")
case'b' printf("7084n")
case'c' printf("6069n")
case d' printf("60n")
default printf("errorn")
2,case
1,int,char
3,case default
a
85100
7084
6069
60
error
c
6069
60
error
caseSwitchSwitchbreakSwitch
Switch(grade)
case'a' printf("85100n")break
case'b' printf("7084n")break
case'c' printf("6069n")break
case d' printf("60n")break
default printf("errorn")
(default)break grade b? 7084”5.12
casecase
(3) case

case'a'
case'b'
case'c' printf("60n")break

grade a? b? c?
main( )
{ int x=1,a=0,b=0;
switch(x){
case 0,b++;
case 1,a++;
case 2,a++;b++;
}
printf(“a=%d,b=%d\n”,a,b);
}
A a=2,b=1
B a=1,b=1
C a=1,b=0
D a=2,b=2
main()
{ int i;
for(i=0;i<3;i++)
switch(i)
{
case 0:printf("%d",i);
case 2:printf("%d",i);
default:printf("%d",i);
}
}
A 22111
B 21021
C 000122
D 00012