计算器问题
程序代码:
#include <windows.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { float Data1,Data2,tempfloat; char Operator; unsigned int temp =0; float (*pFunc)(float,float); for(;;) { printf("Input the first Data to Calculate.\n "); scanf("%f",&Data1); getchar(); if(Data1<1) { printf("Input Wrong Data1 Format!\n"); goto InputFail; } printf("Input the second Data to calculate.\n "); scanf("%f",&Data2); getchar(); if(Data1<1) { printf("Input Wrong Data2 Format!\n"); goto InputFail; } printf("Input the Operator to Calculate(+ - * / ).\n "); scanf("%c",&Operator); getchar(); switch(Operator) { case '+': pFunc= CAdd; break; case '-': pFunc= CSub; break; case '*': pFunc= Cmul; break; case '/': pFunc= Cdiv; break; default :goto InputFail;//printf("Input Wrong Operator Fromat !\n"); } tempfloat =pFunc(Data1,Data2); printf("The Result of Calculate is %9.2f \n",tempfloat ); InputFail: printf("You Will Calculate the Data Continue?(\"Y\" or\"N\")\n"); scanf("%c",&Operator); getchar(); switch(Operator) { case 'Y': case'y': goto InputFail; case 'N': case'n': goto Terminate; default: printf("What do You want to do ? I don't understand.\n"); goto InputFail; } } Terminate: //Program Finished getchar(); return 0; } // define the Function implementation you want to use float CAdd(float d1,float d2) float CAdd(float d1,float d2) { return d1+d2; } float CSub(float d1,float d2) { return d1-d2; } float Cmul(float d1,float d2) { return d1*d2; } float Cdiv(float d1,float d2) { if(d2 ==0) { printf("Dvide by zero ,Error ! \n"); return 0; } return d1/d2; printf("Hello World!\n"); printf("Press ENTER to continue...\n"); getchar(); return 0; }求姐脱!求姐救!求姐压!求姐释!求修改、、为什么能在VS2010中运行,而DEV C++不行?