编程 做了个计算机,但有个错误,找不出?
#include <stdio.h>float f1()
{ float a,b,sum;
printf ("enter two number:"); //输入两个实数
scanf ("%f%f",&a,&b);
sum=a+b;
return sum;
}
float f2()
{ float a,b,sum;
printf ("enter two number:"); //输入两个实数
scanf ("%f%f",&a,&b);
sum=a-b;
return sum;
}
float f3()
{float a,b,sum;
printf ("enter two number:"); //输入两个实数
scanf ("%f%f",&a,&b);
sum=a*b;
return sum;
}
float f4()
{ float a,b,sum;
printf ("enter two number:"); //输入两个实数
scanf ("%f%f",&a,&b);
sum=a/b;
return sum;
}
int f5()
{int i;
printf ("请输入一个十进制的数:%d\n");
scanf ("%d",&i);
printf("输出一个十六进制的数:%x\n",i);
return i;
}
void main()
{int k;
scanf("%d",&k);
printf ("\n\n");
printf("*****计算机菜单*****\n");
printf("*****1 加法运算*****\n");
printf("*****2 减法运算*****\n");
printf("*****3 乘法运算*****\n");
printf("*****4 除法运算*****\n");
printf("*****5 数值转换*****\n");
printf("请选择功能:k\n");
if (K=1)
f1();
else if (k=2)
f2();
else if (k=3)
f3();
else if (k=4)
f4();
else if (k=5)
f5();}