用c 語言編寫簡單的計算器程式,會加減乘除就行,本人初學不太會,特訓求幫助

2021-05-14 10:33:19 字數 6433 閱讀 8247

1樓:匿名使用者

這個是最簡單,簡陋的計算器。很多情況沒考慮進去,例如除數不能為0之類的,真要寫完整的話**還要更多。

**如下:

#include

using namespace std;

int main()

cout << endl << "結果為:" << endl << a << operation << b << "=" << result << endl;

return 0;}

用c++設計乙個簡單的計算器程式,只要求能進行加減乘除運算。

2樓:煙子丹

#include

using std::cin;

using std::cout;

int main()

return 0;

}如果不限定for或while,還有兩種簡單思路:

輸入乙個string遍歷字元,搜尋符號

2.while(cin << int)

while(cin << char)

while(cin << int)

依靠不符型別迴圈跳出來儲存兩個數值,根據儲存的char執行操作

3樓:

是畢業設計用嗎?

我會的 ,,,好不

想用c++編寫乙個計算器程式,只是簡單的加減乘除,但是想實現多數同時運算

4樓:匿名使用者

哇,那你這個需要使用棧呢。

還要有乙個符號優先順序的定義。。。。。

如何用c++編寫乙個連續加減乘除的計算器,函while語句 20

5樓:匿名使用者

#include

#include

#include

#include

#include

#include

#include

using namespace std;

vector> f(string s)

else if (s[i] == ')')else if (s[i] == '+' || s[i] == '-')

else if (s[i] == '*' || s[i] == '/')

else if(s[i] == ' ')

else if (s[i] <= '9' && s[i] >= '0' || s[i] == '.')

}return v;

}bool bijiao(int n, string a)stackf_nbl(vector> v)f.pop();

}else if(f.top() == "(")f.push(xi->second);

else

else

f.push(xi->second);}}}}

}while(f.top() != "#")f.pop();

while(!s.empty())

return f;

}double f_js(stacks)

ch = s.top();

if (s.size())

s.pop();

b = p.size() ? p.top() : 0;

if (p.size())

p.pop();

a = p.size() ? p.top() : 0;

if (p.size())

p.pop();

switch(ch[0])

{case '+' : p.push(a + b); break;

case '-' : p.push(a - b); break;

case '*' : p.push(a * b); break;

case '/' : if(b==0.0){cout<<"除數不能為0"<>s;

cout<

6樓:冰旋華影

你可以看一下,資料結構c語言版,棧那一章

7樓:匿名使用者

要不要處理先乘除後加減?

求用c++做一能加減乘除運算的計算器,要詳細** 5

8樓:匿名使用者

#include

using namespace std;

int main( )

system("pause");}

9樓:

要介面嗎?

介面上要小數點嗎?

用c++編寫一道加減乘除計算器的程式 ?

10樓:w希洛

以下是乙個c#計算器的原始碼,我寫有註釋,你可以看下思想,把它換成vc++的

using system;

using system.drawing;

using system.collections;

using system.componentmodel;

using system.windows.forms;

using system.data;

namespace 計算器

//判斷運算子

private void calc()

stroper="=";

blnfirstopen=true;

textbox1.text=convert.tostring(dblacc);

dblsec=dblacc;

}//小數點的操作

private void btn_clk(object obj,eventargs ea)

//運算子按紐都要呼叫的事件

private void btn_oper(object obj,eventargs ea)

//等號運算

private void ben_equ(object obj,eventargs ea)

//清除按紐操作

private void clear()

//清除按紐

private void btn_clr(object obj,eventargs ea)

////// 清理所有正在使用的資源。

///protected override void dispose( bool disposing )

}base.dispose( disposing );

}#region windows 窗體設計器生成的**

////// 設計器支援所需的方法 - 不要使用**編輯器修改

/// 此方法的內容。

///private void initializecomponent()

);//

// menuitem1

// this.menuitem1.index = 0;

this.menuitem1.text = "退出(&exit)";

this.menuitem1.click += new system.eventhandler(this.menuitem1_click);

// // menuitem2

// this.menuitem2.index = 1;

this.menuitem2.text = "關於zkk計算器";

this.menuitem2.click += new system.eventhandler(this.menuitem2_click);

// // form1

// this.autoscalebasesize = new system.drawing.size(6, 14);

this.clientsize = new system.drawing.size(280, 254);

this.controls.add(this.bclr);

this.controls.add(this.bequ);

this.controls.add(this.bdot);

this.controls.add(this.bdiv);

this.controls.add(this.bmul);

this.controls.add(this.bsub);

this.controls.add(this.bplus);

this.controls.add(this.button10);

this.controls.add(this.button9);

this.controls.add(this.button8);

this.controls.add(this.button7);

this.controls.add(this.button6);

this.controls.add(this.button5);

this.controls.add(this.button4);

this.controls.add(this.button3);

this.controls.add(this.button2);

this.controls.add(this.button1);

this.controls.add(this.textbox1);

this.icon = ((system.drawing.icon)(resources.getobject("$this.icon")));

this.menu = this.mainmenu1;

this.name = "form1";

this.text = "zkk計算器1.02威力加強版";

this.resumelayout(false);

}#endregion

////// 應用程式的主入口點。///

用c++編寫乙個加減乘除 的運算題 求完整**

11樓:魔龍嗜血

#include

#include

#include

#define maxop 100

#define number '0'

int getop (char );

void push (double);

double pop(void);

int getch(void);

void ungetch(int);

int getop(char s)

#define bufsize 100

char buf[bufsize];

int bufp=0;

int getch(void)

void ungetch(int c)

main()

}return 0;

}#define maxval 100

int sp=0;

double val[maxval];

void push(double f)}

12樓:匿名使用者

如果你是老師問你的話,可以給你**,如果是用在實際生活中的話,就不可以了。

用c++語言定義乙個類,實現加減乘除運算

13樓:

#include

class cmy_math

;cmy_math::cmy_math()

cmy_math::~cmy_math()

double cmy_math::add(double a,double b)

double cmy_math::subtract(double a,double b)

double cmy_math::mult(double a,double b)

double cmy_math::div(double a,double b)

int main(double argc, char* argv)

設計乙個最簡單的c++加減乘除的程式

14樓:周亮

#include

using namespace std;

class cpu

cpu(char atype)

char get_type()

private:

char type;

};class ram

ram(char atype)

char get_type()

private:

char type;

};class cdrom

};class computer

void run()

void stop()

char get_cpu()

char get_ram()

private:

cpu acpu;

ram aram;

cdrom acdrom;

};int main()

題目18 用C語言設計簡單的計算器,要求能夠對輸入的數

include include include int deal int op1,int op2,char op 運算 return op1 char replace char source,char sub,char rep 字串替換 else pc1 source source pc1 null...

用c語言編寫12320?的程式,用C語言編寫1!2!3!20!?的程式

include int fun int int main printf d n sum 輸出算式結果return 0 int fun int i 階乘函式 採用函式遞迴呼叫return 1 include void main printf d n sum include include long l...

用pascal語言寫個簡易計算器程式

const m 1000 type stack array 1.m of extended stack2 array 1.m of char var s stack s2 stack2 a,e string t,i,x,y integer j,k extended w char cha set of...