C 實現簡單計算器功能

2022-09-26 03:33:07 字數 2601 閱讀 8331

實現效果:

form1.cs**:

using system;

using system.collections.generic;

using system.componentmodel;

using system.data;

using system.drawing;

using system.linq;

using system.text;

using system.threading.tasks;

using system.windows.forms;

namespace cal

private void eq_click(object sender, eventargs e)

catch (exception)

finally

break;

//減法運算

case 2:

trycatch (exception)

finally

break;

//乘法運算

case 3:

trycatch (exception)

finally

break;

//除法運算,討論分母為零的情況

case 4:

if (double.parse(result.text)==0)

else

break;

case 5:

trycatch (exception)

finally

break;}}

private void empty_click(object sender, eventargs e)

}private void zero_click(object sender, eventargs e)

else

}private void one_click(object sender, eventargs e)

else

}private void two_click(object sender, eventargs e)

else

}private void three_click(object sender, eventargs e)

else

}private void four_click(object sender, eventargs e)

else

}private void five_click(object sender, eventargs e)

else

}程式設計客棧 void six_click(object sender, eventargs e)

else

}private void seven_click(object sender, eventargs e)

else

}private void eight_click(object sender, eventargs ewww.cppcns.com)

else

}private void nine_click(object sender, eventargs e)

else

}private void point_click(object sender, eventargs e)

//如果再次輸入.則返回都輸入的字元後邊並提示資訊

else if (result.text.indexof(".") >= 0)

else

}private void add_click(object sender, eventargs e)

catch (exception)

finally

}private void mul_click(object sender, eventargs e)

catch (exception)

finally

}private void sub_click(object sender, eventargs e)

catch(exception)

finally

}private void button1_click(object sender, eventargs e)

catch (exception)

finally

}private void per_click(object sender, eventargs e)

catch (exception)

finally

}private void opp_click(object sender, eventargs e)

catch (exception)

finally

}private void form1_load(object sender, eventargs e)

private void result_textchanged(object sender, eventargs e)

if (result.text.length > 36&&result.text.length<45)

if (result.text.length > 45)}}}

本文標題: c#實現簡單計算器功能

本文位址:

C 實現簡單計算器功能

c 實現簡單計算器的具體 供大家參考,具體內容如下 要求 輸入乙個包含 的非負整數計算表示式,計算表示式的值,每個字元之間需有乙個空格,若一行輸入為0,則退出程式。輸入樣例 4 2 5 7 11 輸出樣例 13.36 實現 include include using namespace std ch...

C 實現計算器功能

注意 判斷數值和表示式 的合理性。include include include define max len 200 判斷字元是否合理 0 9 bool checkinput char c if c 0x2e c 0x2b c 0x2d c 0x2a c 0x2f return false boo...

C 實現簡單計算器

要求 輸入乙個包含 的非負整數計算表示式,計算表示式的值,每個字元之間需有乙個空格,若一行輸入為0,則退出程式。輸入樣例 4 2 5 7 11 輸出樣例 13.36 實現 include include using namespace std char str 200 儲存表示式字串 int mat...