则么用C语言编写一个简单的计算机程序要求会加减乘除开根号
来源:百度知道 编辑:UC知道 时间:2024/07/03 13:24:22
本人C语言学的不是很好请各位大虾帮帮帮,还有小弟的积分不多了这是全部的请帮帮忙吧,急用。
+
-
*
/
sqrt()
void main()
{
int relation=0;
double a,b;
cin>>a;
cout<<endl;
switch(c=getchar())
{
case '+':relation=1;break;
case '-':relation=2;break;
case '*':relation=3;break;
case '/':relation=4;break;
}
cout<<endl;
cin>>b;
cout<<endl;
int r;
switch(relation)
{
case 1:r=a+b;break;
case 2:r=a-b;break;
case 3:r=a*b;break;
case 4:r=a/b;break;
}
cout<<r;
}
楼上是C++..我改了一下:
#include <math.h>
void main()
{
int relation=0;
double a,b,r;
printf("Input the Numbers(like:5,20)/n");
scanf("%f,%f",&a,&b);
printf("Choose +:1 -:2 *:3 /:4 sqrt:5/n");
scanf("%d",&relation);
switch(relation)
{
ca