| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1093 人关注过本帖
标题:计算器程序,无法正确输出最后的结果!
取消只看楼主 加入收藏
含笑半步颠
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-2-27
收藏
 问题点数:0 回复次数:3 
计算器程序,无法正确输出最后的结果!
// c++ code template
#include <iostream.h>
void main()
{
float num1;
float num2;
char op;
float ans;
cout << "Please enter a number: " ;
cin >> num1;
cout << "please entet another nunber: " ;
cin >> num2;
cout << "press A to add the two numbers."
<< endl
<< "press S to subtract the two numbers."
<< endl
<< "press M to multiply the two numbers."
<< endl
<< "press D to divide the two numbers."
<< endl;
cin.ignore();
cin >> op;
if (op == 65)
{
ans = num1 + num2;
cout << "The answet is " << ans << endl;
}
if (op == 83)
{
ans = num1 - num2;
cout << "The answet is " << ans << endl;
}
if (op == 77)
{
ans = num1 * num2;
cout << "The answet is " << ans << endl;
}
if (op == 68)
{
ans = num1 / num2;
cout << "The answet is: " << ans << endl;
}
if (op != 65 && op !=83 && op != 77 && op != 68)
{
cout << "No valid operation was chosen!" << endl;
}
}
没有输出最后的结果!?

[此贴子已经被作者于2007-3-8 10:09:03编辑过]

搜索更多相关主题的帖子: 计算器 结果 输出 
2007-03-07 22:35
含笑半步颠
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-2-27
收藏
得分:0 
图片附件: 游客没有浏览图片的权限,请 登录注册

显示是这样 我照你给的方法改过来了
2007-03-08 10:07
含笑半步颠
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-2-27
收藏
得分:0 

哦哦~
知道了~ 待研究研究!

2007-03-08 20:56
含笑半步颠
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-2-27
收藏
得分:0 
不知道啦~ 我也是用VC6.0
老是没结果
2007-03-11 21:05
快速回复:计算器程序,无法正确输出最后的结果!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012825 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved