精品熟女碰碰人人a久久,多姿,欧美欧美a v日韩中文字幕,日本福利片秋霞国产午夜,欧美成人禁片在线观看

C 語言實例 – 實現簡單的計算器

C 語言實例 - 實現簡單的計算器

C 語言實例 C 語言實例

實現加減乘除計算。

實例

# include <stdio.h> int main() { char operator; double firstNumber,secondNumber; printf("輸入操作符 (+, -, *, /): "); scanf("%c", &operator); printf("輸入兩個數字: "); 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; }

輸出結果為:

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

C 語言實例 C 語言實例

相關文章