#include<stdio.h>
int main()
{
char a='a';
double b=0;
loop: printf("do you choose \nF(Fahrenheit degree translate degree Celsius )\nor \nD(degree Celsius translate Fahrenheit degree):");
scanf("%c",&a);
if(a == 'F')
{
printf("please input a number:");
scanf("%lf",&b);
b=(b-32)*5/9;
printf("result is %.2lf\n",b);
}
if(a == 'D')
{
printf("please input a number:");
scanf("%lf",&b);
b=b*1.8+32;
printf("result is %.2lf\n",b);
}
else
{
printf("Warn:it is a error input,please resume input!!!!!\n");
goto loop;
}
return 0;
}
用goto返回开始重新输入,但中间出现一段不需要的代码,可以怎样解决
qq_安逸_4
望远
相关分类