
1个回答
展开全部
#include <string.h>
#include "stdafx.h"
#include <stdio.h>
char e;
float main(float x, float y)
{
void action(float x,float y);
void action1(float x,float y);
void action2(float x,float y);
void action3(float x,float y);
do
{
printf("输入两个数:\n");
scanf("%f%f",&x,&y);
printf("x=%.2f\n",x);
printf("y=%.2f\n",y);
printf("请输入要选择的算法符号:+-*/\n");
scanf("\n%c",&e);
if (e!='+'&&e!='-'&&e!='*'&&e!='/')
{
printf("error op .please input a new one:\n");
printf("请输入要选择的算法符号:+-*/\n");
scanf("\n%c",&e);
}
switch (e)
{
case '+': action(x,y);
break;
case '-': action1(x,y);
break;
case '*': action2(x,y);
break;
case '/': action3(x,y);
break;
}
} while (1);
return 0;
}
void action(float x,float y)
{
float sum;
sum=x+y;
printf("x+y=%.2f\n",sum);
}
void action1(float x,float y)
{
float a;
a=x-y;
printf("x-y=%.2f\n",a);
}
void action2(float x,float y)
{
float b;
b=x*y;
printf("x*y=%.2f\n",b);
}
void action3(float x,float y)
{
float q;
if(y!=0){
q=x/y;
printf("x/y=%.2f\n",q);
}else
printf("除数不能为零!");
}
#include "stdafx.h"
#include <stdio.h>
char e;
float main(float x, float y)
{
void action(float x,float y);
void action1(float x,float y);
void action2(float x,float y);
void action3(float x,float y);
do
{
printf("输入两个数:\n");
scanf("%f%f",&x,&y);
printf("x=%.2f\n",x);
printf("y=%.2f\n",y);
printf("请输入要选择的算法符号:+-*/\n");
scanf("\n%c",&e);
if (e!='+'&&e!='-'&&e!='*'&&e!='/')
{
printf("error op .please input a new one:\n");
printf("请输入要选择的算法符号:+-*/\n");
scanf("\n%c",&e);
}
switch (e)
{
case '+': action(x,y);
break;
case '-': action1(x,y);
break;
case '*': action2(x,y);
break;
case '/': action3(x,y);
break;
}
} while (1);
return 0;
}
void action(float x,float y)
{
float sum;
sum=x+y;
printf("x+y=%.2f\n",sum);
}
void action1(float x,float y)
{
float a;
a=x-y;
printf("x-y=%.2f\n",a);
}
void action2(float x,float y)
{
float b;
b=x*y;
printf("x*y=%.2f\n",b);
}
void action3(float x,float y)
{
float q;
if(y!=0){
q=x/y;
printf("x/y=%.2f\n",q);
}else
printf("除数不能为零!");
}
参考资料: http://hi.baidu.com/laijian_software/ihome/myblog
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |