以下是引用zqy110007在2009-8-22 22:34的发言:回复 4楼 soler是你的机子, 很可能是浏览器被人动了手脚`
我用ie看看,是不是还是这样子。。。
#include #include char choose_menu(void);float get_float(void);void mainFunction(char choice, float num1, float num2);int main(void){ char choice; choice = choose_menu(); while(choice != 'q') { float num1,num2; printf("Enter first number:\n"); num1 = get_float(); printf("Enter second number:\n"); num2 = get_float(); mainFunction(choice, num1, num2); choice = choose_menu(); } return 0;}char choose_menu(void){ char choice; printf("\nEnter the operation of your choice:\n"); printf("a. add s. subtract \n"); printf("m. multipy d. divide \n"); printf("q. quit \n"); choice = getchar(); while(!((choice == 'a' || choice == 'm' || choice == 'q' || choice == 's' || choice == 'd') && getchar() == '\n')) { while(getchar() != '\n') continue; system("cls"); printf("\n\n"); printf("Enter the right operation of your choice again:\n"); printf("a. add s. subtract \n"); printf("m. multipy d. divide \n"); printf("q. quit \n"); printf("Attention: input character a, s, m, d or q:"); choice = getchar(); } return choice;}float get_float(void){ float num; char ch; while(scanf("%f",&num) != 1) { while((ch=getchar()) != '\n') putchar(ch); printf(" is not an float.\n please enter an "); printf("float value, such as 11.0, 124.5 or 2.3333:\n"); } getchar(); return num;}void mainFunction(char choice, float num1, float num2){ printf("------------------------------------------------------"); switch( choice) { case 'a':printf("\n\t%.2f add %.2f EQU %.2f.\n", num1, num2, num1 + num2); break; case 's':printf("\n\t%.2f subtract %.2f EQU %.2f.\n", num1, num2, num1 - num2); break; case 'm':printf("\n\t%.2f multiply %.2f EQU %.4f.\n", num1, num2, num1 * num2); break; case 'd':if(num2 != 0) { printf("\n\t%.2f divide %.2f EQU %.2f.\n", num1, num2, num1 / num2); break; } else printf("\n\tError: the divide number cannot be zero!\n"); } printf("------------------------------------------------------");}