用C++实现的命令行计算器
来源:互联网 发布:淘宝卖家转接人工服务 编辑:程序博客网 时间:2024/04/28 20:33
C++实现的命令行计算器。
只进行加减乘除运算,没有进行异常判断。没啥技术含量,直接贴代码。
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
#include <string>
#include <stdlib.h>
using namespace std;
void main() {
cout << " ********************************************************" << endl;
cout << " 命令行计算器" << endl << endl;
cout << " 1.用法介绍:第一次先输入一个数字,然后回车" << endl;
cout << " 2.输入运算符号,然后回车" << endl;
cout << " 3.再次输入一个数字,然后回车,程序会自动运算出结果" << endl;
cout << " 4.输入exit退出程序" << endl;
cout << " ********************************************************" << endl;
cout << " ********************************************************" << endl;
cout << " 命令行计算器" << endl << endl;
cout << " 1.用法介绍:第一次先输入一个数字,然后回车" << endl;
cout << " 2.输入运算符号,然后回车" << endl;
cout << " 3.再次输入一个数字,然后回车,程序会自动运算出结果" << endl;
cout << " 4.输入exit退出程序" << endl;
cout << " ********************************************************" << endl;
string leftParStr;
int leftParInt;
int rightParInt;
string rightParStr;
string calculator;
int leftParInt;
int rightParInt;
string rightParStr;
string calculator;
while(true) {
cout << "1.请输入运算左值:";
cin >> leftParStr;
cout << "1.请输入运算左值:";
cin >> leftParStr;
if(leftParStr == "exit")
return;
return;
cout << "2.请输入运算符:";
cin >> calculator;
cin >> calculator;
if(calculator == "exit")
return;
return;
cout << "3.请输入运算右值:";
cin >> rightParStr;
cin >> rightParStr;
if(rightParStr == "exit")
return;
return;
leftParInt = atoi(leftParStr.c_str());
rightParInt = atoi(rightParStr.c_str());
rightParInt = atoi(rightParStr.c_str());
if(calculator == "+") {
cout << " The result of this calculator is: " << leftParInt + rightParInt << endl;
}
cout << " The result of this calculator is: " << leftParInt + rightParInt << endl;
}
///*
if(calculator == "-") {
cout << " The result of this calculator is: " << leftParInt - rightParInt << endl;
}
if(calculator == "-") {
cout << " The result of this calculator is: " << leftParInt - rightParInt << endl;
}
if(calculator == "*") {
cout << " The result of this calculator is: " << leftParInt * rightParInt << endl;
}
cout << " The result of this calculator is: " << leftParInt * rightParInt << endl;
}
if(calculator == "/") {
cout << " The result of this calculator is: " << leftParInt / rightParInt << endl;
}
cout << " The result of this calculator is: " << leftParInt / rightParInt << endl;
}
}
}
}
- 用C++实现的命令行计算器
- C++实现的命令行计算器。
- 一个用C实现的科学计算器
- 用C语言实现的计算器
- 利用搜索引擎实现命令行计算器
- 【CSharp】简易命令行计算器实现
- 用C语言实现一个简单的计算器代码
- C语言实现一个简单的计算器
- 一个计算器的C语言实现
- C语言实现的高精度计算器
- 【C++】C++顺序栈实现的计算器
- 用C语言实现一个计算器
- c用栈实现逆波兰计算器
- c语言实现计算器
- C++-------实现计算器
- 简单计算器实现(C++)
- 计算器实现(c++)
- C语言实现计算器
- Pascal 语言中的关键字及保留字
- System 提供的编译期函数
- vc 读取txt
- Ubuntu 11.04 安装后要做的20件事
- vc 连接access
- 用C++实现的命令行计算器
- AVI转YUV的详细过程以及注意事项
- 浅谈 Oracle 监听器
- 迅雷精简版1.4.2.146去BT文件自动关联
- mtk 调试方法总结
- 风云离职之创业公司的技术人才
- Delphi 关键字详解[整理于 "橙子" 的帖子]
- Linux内核一个模块调另一个模块的函数
- Ant一些基本介绍