请将下面的程序段改用嵌套的IF语句实现
#include<stdio.h>voidmain(){ints,t,x,y,z;scanf("%d,%d,%d",&s,&x,&y);t=(int)(s/10);swi...
#include<stdio.h>
void main()
{
int s,t,x,y,z;
scanf("%d,%d,%d",&s,&x,&y);
t=(int)(s/10);
switch(t){
case 10:
case 9:z=x*x-y*y;break;
case 8: z=2*x+3*y;break;
case 7:
case 6:z=x-y;break;
case 5:
case 4:
case 3:z=x*y;break;
case 2:
case 1:
case 0:z=x;break;
default :z=x*x+y*y;
}
printf("z=%d",z);
} 展开
void main()
{
int s,t,x,y,z;
scanf("%d,%d,%d",&s,&x,&y);
t=(int)(s/10);
switch(t){
case 10:
case 9:z=x*x-y*y;break;
case 8: z=2*x+3*y;break;
case 7:
case 6:z=x-y;break;
case 5:
case 4:
case 3:z=x*y;break;
case 2:
case 1:
case 0:z=x;break;
default :z=x*x+y*y;
}
printf("z=%d",z);
} 展开
2个回答
展开全部
#include<stdio.h>
void main()
{
int s,t,x,y,z;
scanf("%d,%d,%d",&s,&x,&y);
t=(int)(s/10);
if (t==10||t==9) z=x*x-y*y;
else if (t==8) z=2*x+3*y;
else if (t==7||t==6) z=x-y;
else if (t==5||t==4||t==3) z=x*y;
else if (t==2||t==1||t==0) z=x;
else z=x*x+y*y;
printf("z=%d",z);
}
void main()
{
int s,t,x,y,z;
scanf("%d,%d,%d",&s,&x,&y);
t=(int)(s/10);
if (t==10||t==9) z=x*x-y*y;
else if (t==8) z=2*x+3*y;
else if (t==7||t==6) z=x-y;
else if (t==5||t==4||t==3) z=x*y;
else if (t==2||t==1||t==0) z=x;
else z=x*x+y*y;
printf("z=%d",z);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询