日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

c++语言编辑简单的计算器,c++编写简单的计算器程序

發(fā)布時間:2025/3/21 c/c++ 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c++语言编辑简单的计算器,c++编写简单的计算器程序 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

首先來看下本人的開發(fā)環(huán)境

系統(tǒng):win7

電腦:dell

運行環(huán)境:vs2015

語言:c++

簡單計算器代碼

//四則運算

#include "stdafx.h"

#include

#include

using namespace std;

void add()

{

printf("輸入要計算的加數(shù)(例如a b)\n");

int adda=0, addb=0,addc=0;

cin >> adda;

cin >> addb;

addc = adda+addb;

cout <

}

void substraction()

{

printf("輸入要計算的減數(shù)(例如a b)\n");

int suba = 0, subb = 0, subc = 0;

cin >> suba;

cin >> subb;

subc = suba-subb;

cout <

}

void multiplication()

{

printf("輸入要計算的乘數(shù)(例如a b)\n");

int mula = 0, mulb = 0, mulc = 0;

cin >> mula;

cin >> mulb;

mulc = mula*mulb;

cout <

}

void division()

{

printf("輸入要計算的除數(shù)(例如a b)\n");

int dsa = 0, dsb = 0, dsc = 0,dsd=0;

cin >> dsa;

cin >> dsb;

dsc = dsa/dsb;

dsd = dsa%dsb;

cout <

}

void operation()//運算函數(shù)

{

printf("輸入數(shù)據(jù)選擇做那種運算\n");

printf("輸入0選擇退出,1做加法,2做減法,3做乘法,4做除法(保留余數(shù))\n");

int operatione = 0;

cin >> operatione;

cout << endl;

try

{

if (operatione == 1)

{

//加法

add();

}

else if (operatione == 2)

{

//減法

substraction();

}

else if (operatione == 3)

{

//乘法

multiplication();

}

else if (operatione == 4)

{

//出發(fā)

division();

}

else if (operatione == 0)

{

exit(0);

}

else

{

throw 1;

}

}

catch (int i)

{

cout << "輸入錯誤" << endl;

}

operation();

}

int main()

{

printf("歡迎使用本計算器");

operation();

return 0;

}

代碼比較簡單,希望大家能夠喜歡

總結(jié)

以上是生活随笔為你收集整理的c++语言编辑简单的计算器,c++编写简单的计算器程序的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。