70,023
社区成员




- #include <stdio.h>
- #include <ctype.h>
- int main(void)
- {
- double number2,number1;
- char operation;
- char x;
-
- select1 :
- {printf("Input number1 operation number2!");
- scanf("%lf %c %lf",&number1,&operation,&number2);
- switch (operation)
- {
- case '+':
- printf("%.2lf %c %.2lf = %.2lf",number1,operation,number2,number2+number1);
- printf("Would u need another calculation?y for yes, and N for NO!\n");
- scanf("%c",&x);
- if (toupper(x)=='Y')
- {
- goto select1;
- }
- else break;
- case '-':
- printf("%.2lf %c %.2lf = %.2lf\n",number1,operation,number2,number2+number1);
- printf("Would u need another calculation?y for yes, and N for NO!\n");
- scanf("%c",&x);
- if (toupper(x)=='Y')
- {
- goto select1;
-
- }
- else break;
- case '/':
- if (number2==0)
- {
- printf("Sorry!iput the right number!");
- break;
- }
- else
- printf("%.2lf %c %.2lf = %.2lf\n",number1,operation,number2,number1/number2);
- printf("Would u need another calculation?y for yes, and N for NO!\n");
- scanf("%c",&x);
- if (toupper(x)=='Y')
- {
- goto select1;
-
- }
- else break;
- case '*':
- printf("%.2lf %c %.2lf = %.2lf\n",number1,operation,number2,number1*number2);
- printf("Would u need another calculation?y for yes, and N for NO!\n");
- scanf("%c",&x);
- if (toupper(x)=='Y')
- {
- goto select1;
-
- }
- else break;
- }
- }
-
-
- return 0;
- }
case '+':
printf("%.2lf %c %.2lf = %.2lf\n",number1,operation,number2,number2+number1);
printf("Would u need another calculation?y for yes, and N for NO!\n");
scanf("%c",&x);
if (toupper(x)=='Y')
{
goto select1;
}
else break;
#include <stdio.h>
#include <ctype.h>
int main(void)
{
double number2,number1;
char operation;
char x;
select1 :
{printf("Input number1 operation number2!\n");
scanf("%lf %c %lf",&number1,&operation,&number2);
fflush(stdin);//刷新下
switch (operation)
{
case '+':
printf("%.2lf %c %.2lf = %.2lf",number1,operation,number2,number2+number1);
printf("Would u need another calculation?y for yes, and N for NO!\n");
scanf("%c",&x);
if (toupper(x)=='Y')
{
goto select1;
}
else break;
case '-':
printf("%.2lf %c %.2lf = %.2lf\n",number1,operation,number2,number2+number1);
printf("Would u need another calculation?y for yes, and N for NO!\n");
scanf("%c",&x);
if (toupper(x)=='Y')
{
goto select1;
}
else break;
case '/':
if (number2==0)
{
printf("Sorry!iput the right number!");
break;
}
else
printf("%.2lf %c %.2lf = %.2lf\n",number1,operation,number2,number1/number2);
printf("Would u need another calculation?y for yes, and N for NO!\n");
scanf("%c",&x);
if (toupper(x)=='Y')
{
goto select1;
}
else break;
case '*':
printf("%.2lf %c %.2lf = %.2lf\n",number1,operation,number2,number1*number2);
printf("Would u need another calculation?y for yes, and N for NO!\n");
scanf("%c",&x);
if (toupper(x)=='Y')
{
goto select1;
}
else break;
}
}
return 0;
}
select1 :
{printf("Input number1 operation number2!");
scanf("%lf %c %lf",&number1,&operation,&number2);
getchar();//在这儿加个这个就好了