首先来看下本人的开发环境
系统:win7
电脑:dell
运行环境:vs2015
语言:c++
简单计算器代码
//四则运算 #include "stdafx.h" #include#include using namespace std; void add() { printf("输入要计算的加数(例如a b)n"); int adda=0, addb=0,addc=0; cin >> adda; cin >> addb; addc = adda+addb; cout <> suba; cin >> subb; subc = suba-subb; cout < > mula; cin >> mulb; mulc = mula*mulb; cout < > dsa; cin >> dsb; dsc = dsa/dsb; dsd = dsa%dsb; cout < > operatione; cout << endl; try { if (operatione == 1) { //加法 add(); } else if (operatione == 2) { //减法 substraction(); } else if (operatione == 3) { //乘法 multiplication(); } else if (operatione == 4) { //出发 division(); } else if (operatione == 0) { exit(0); } else { throw 1; } } catch (int i) { cout << "输入错误" << endl; } operation(); } int main() { printf("欢迎使用本计算器"); operation(); return 0; }
代码比较简单,希望大家能够喜欢



