编写一个C程序,能够从键盘输入一个浮点数,然后计算输出它得倒数。
答案:3 悬赏:0
解决时间 2021-02-19 03:46
- 提问者网友:曖昧情执
- 2021-02-18 06:28
编写一个C程序,能够从键盘输入一个浮点数,然后计算输出它得倒数。
最佳答案
- 二级知识专家网友:不傲怎称霸
- 2021-02-18 07:52
#include
void main()
{
float x;
printf("请输入浮点数:");
scanf("%f",&x);
if(x !
void main()
{
float x;
printf("请输入浮点数:");
scanf("%f",&x);
if(x !
全部回答
- 1楼网友:高冷不撩人
- 2021-02-18 09:00
#include <stdio.h>
#include <stdlib.h>
void main()
{
float in;
char ch;
printf("input 'x' to exit.\n");
while(true)
{
printf("input a float:");
scanf("%f",&in);
getchar();
if(in != 0)
{
printf("1/%f=%f\n",in,1/in);
}
else
{
printf("sorry, your input error.");
}
printf("wanna exit?:");
ch = getchar();
if(ch == 'x' || ch == 'X')
{
break;
}
}
getchar();
}
- 2楼网友:滚出爷的世界
- 2021-02-18 08:11
#include <stdio.h>
void main()
{
float x;
printf("请输入浮点数:");
scanf("%f",&x);
if(x != 0)
{
printf("1/%f=%f\n",x,1/x);
}
else
{
printf("不要开玩笑,老兄,0可以当除数吗?");
}
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯
• 手机登qq时,显示手机磁盘不足,清理后重新登 |
• 刺客的套装怎么选啊? |