有关c语言进行简单的输入菜单选择,并由此进行三角函数的简单计算。代码如下:
#include<stdio.h>
#include<math.h>
float theta = 0.0;
int value = 0;
int main(){
printf("please input the size the angle:%f\n",theta);
printf("if you want to calculate the value os sin, please input 1,else input 2 to ca"\
"lculate cos,else if the value is 3 , it will calculate tan().\n");
scanf("%d",&value);
if(value==1){
scanf("%f",&theta);
printf("the sin value of this angle is %f.\n",sin((double)theta));
}
else if(value == 2){
scanf("%f",&theta);
printf("the cos value of this angle is %f.\n",cos((double)theta));
}
else if(value == 3){
scanf("%f",&theta);
printf("the tan value of this angle is %f.\n",tan((double)theta));
}
}
具体效果如下:



由此可见,不在菜单选项之内,将不会有答案输出。如有疑问,请您留言。

被折叠的 条评论
为什么被折叠?



