标签:bre 优先 utc enter 包括 return main printf oat
#include <stdio.h> int main(void){ float a, b; char ch; printf("Enter an expression:"); scanf("%f", &a); printf("%.3f", a); ch = getchar(); putchar(ch); while (ch != ‘\n‘) { scanf("%f", &b); printf("%.3f", b); switch(ch){ case ‘+‘: a += b; break; case ‘-‘: a -= b; break; case ‘*‘: a *= b; break; case ‘/‘: a /= b; break; } ch = getchar(); putchar(ch); } printf("%.3f\n", a); return 0; }
例如输入:1+2.5*3
输出:10.5
表达式从左向右求值(所有运算符的优先级都一样,仅包括+ - * /)
标签:bre 优先 utc enter 包括 return main printf oat
原文地址:http://www.cnblogs.com/jack-zander/p/7613109.html