实现输入两个实数和一个四则运算符(+,—,*,/)
#include <stdio.h>
void main()
{
double x,y,result;
char op;
int flag;
printf("Input x,y,op:\n");
scanf("%lf%lf%c",&x,&y,&op);
flag=1;
switch (op)
{
case '+' :result=x+y;break;
case '-' :result=x-y;break;
case '*' :result=x*y;break;
case '/' :
if (y!=0)
result=x/y;
else
flag=0;
break;
default: flag=1;
break;
printf("result=%f\n",result);
else
printf("invalid input y or op\n");
}
#include <stdio.h>
void main()
{
int i,j,k,1=1;
for(i=1;i<50;i++)
for(j=0;j<50;j++)
{k=result;
if(flag=1)
{
printf("%2d%2d%2d",i,j,k);
break;
if(1%5==0)printf("\n");
}
}
}