問答題

【簡答題】編程實(shí)現(xiàn)簡單的計(jì)算器功能,要求用戶按如下格式從鍵盤輸入算式:操作數(shù)1運(yùn)算符op操作數(shù)2計(jì)算并輸出表達(dá)式的值,其中算術(shù)運(yùn)算符包括:加(+)、減(-)、乘(*)、除(/)。**輸入格式要求:%d%c%d提示信息:Pleaseenteranexpression:**輸出格式要求:%d+%d=%d\n%d-%d=%d\n%d*%d=%d\n%d/%d=%d\nDivisionbyzero!\nInvalidoperator!\n程序運(yùn)行示例1如下:Pleaseenteranexpression:22+1222+12=34程序運(yùn)行示例2如下:Pleaseenteranexpression:22-1222-12=10程序運(yùn)行示例3如下:Pleaseenteranexpression:22*1222*12=264程序運(yùn)行示例4如下:Pleaseenteranexpression:22/1222/12=1程序運(yùn)行示例5如下:Pleaseenteranexpression:22/0Divisionbyzero!程序運(yùn)行示例6如下:Pleaseenteranexpression:22\12Invalidoperator!

答案:

微信掃碼免費(fèi)搜題