黄色电影一区二区,韩国少妇自慰A片免费看,精品人妻少妇一级毛片免费蜜桃AV按摩师 ,超碰 香蕉

C 語(yǔ)言實(shí)例 – 實(shí)現(xiàn)簡(jiǎn)單的計(jì)算器

C 語(yǔ)言實(shí)例 - 實(shí)現(xiàn)簡(jiǎn)單的計(jì)算器

C 語(yǔ)言實(shí)例 C 語(yǔ)言實(shí)例

實(shí)現(xiàn)加減乘除計(jì)算。

實(shí)例

# include <stdio.h> int main() { char operator; double firstNumber,secondNumber; printf("輸入操作符 (+, -, *, /): "); scanf("%c", &operator); printf("輸入兩個(gè)數(shù)字: "); scanf("%lf %lf",&firstNumber, &secondNumber); switch(operator) { case '+': printf("%.1lf + %.1lf = %.1lf",firstNumber, secondNumber, firstNumber + secondNumber); break; case '-': printf("%.1lf - %.1lf = %.1lf",firstNumber, secondNumber, firstNumber - secondNumber); break; case '*': printf("%.1lf * %.1lf = %.1lf",firstNumber, secondNumber, firstNumber * secondNumber); break; case '/': printf("%.1lf / %.1lf = %.1lf",firstNumber, secondNumber, firstNumber / secondNumber); break; // operator doesn't match any case constant (+, -, *, /) default: printf("Error! operator is not correct"); } return 0; }

輸出結(jié)果為:

輸入操作符 (+, -, *, /): *
輸入兩個(gè)數(shù)字: 4 5
4.0 * 5.0 = 20.0

C 語(yǔ)言實(shí)例 C 語(yǔ)言實(shí)例

相關(guān)文章