{inta=1,b=0; scanf(“%d”,&a);
switch(a)
{case1:b=1;break; case2:b=2;break; default:b=10;} printf(\; }
若键盘输入5,运行结果为:10 16.
#include
{chargrade=’C’; switch(grade)
{case‘A’:printf(“90-100\\n”); case‘B’:printf(“80-90\\n”);
case‘C’:printf(“70-80\\n”); case‘D’:printf(“60-70\\n”);break; case‘E’:printf(“<60\\n”); default:printf(“error!\\n”);
} } 运行结果为: 70-80 60-70
17.
#include
main()
{inty=9; for(;y>0;y--) if(y%3==0)
{printf(%d”,--y);
continue; }
}
运行结果为: 852 18.
#include
{inti,sum=0;i=1;
do{sum=sum+i;i++;}while(i<=10);
printf(“%d”,sum);
}
运行结果为:55 19.
#include
main() {inti; intx1=1,x2=2; printf(\ for(i=1;i<=N;i++)
{printf(\ if(i%2==0)
printf(\ x1=x1+x2; x2=x2+x1; } }
运行结果为: 1235 8132134
20
#include
for(x=30,y=0;x>=10,y<10;x--,y++) x/=2,y+=2;
printf(“x=%d,y=%d\\n”,x,y); } 运行结果为: x=0,y=12 21.
#include