חישוב משוואות ב-c++

חישוב משוואות ב-c++

main() { int i,p,t=0; static dbl nNum[EQUA_MAX]; enum Action {plus, minus, multi, subt} nSign[EQUA_MAX]; bool deci=false; // decimal point state flag dbl ans=0; // equation solution static char equa[EQUA_MAX]; // equation up to EQUA_MAX+1 chars while(1>0) { cin.getline(equa,EQUA_MAX); for(i=0; equa != '\0'; i++) { if(equa>='0' && equa<='9') { if(!deci) { nNum[t] *= 10 ; nNum[t] += ( equa - '0' ) ; } else { nNum [t] /= 10 ; nNum[t] += ( equa - '0' ) / 10 ; } } else { switch(equa) { case '+': nSign[t] = plus; break; case '-': nSign[t] = minus;break; case '*': nSign[t] = multi;break; case '/': nSign[t] = subt; break; case '.': if(deci) deci=false; else deci=true; break; case 'p': if(equa[i+1]=='i') nNum[t]=3.1415926535; break; } if(!deci) t++; // moving to next component } } for(i=0; i<=t-1; i++) { switch(nSign) { case plus: cout<<"+"; break; case minus: cout<<"-"; break; case multi: cout<<"*";break; case subt: cout<<"/";break; } cout<<nNum<<" "; }

This program is compiled successfully with dev c++ but it doesn't work well. The program gets the user equation and then organize the date. Every number in the string is a number of the nNum[] array. Every mathematical sign is going to the nSign[] array.
An example: User Input: "1+2*4" Output: "1 + 2 * 4" // every space signals a new member in either nNum[] or nSign​
plz help me to figure out what is wrong and why the program couldn't output correctly. Thanks, :eek: ; שלום. אם תוכלו לעזור לי במציאת הבעיה בתוכנית זו זה יעזור לי מאוד. התוכנית קולטת מחרוזת equa[] ולאחר מכן אמורה להציג אותה פעם נוספת אך במקום למשל "123" להציג משתנה מסוג int ששווה ל-123, משתנה זה הוא אחד מהמשתנים במערך nSign שהוא מערך פעולות החשבון. מערך המספרים שנמצאים במחרוזת הנקלטת על ידי המשתמש הוא nNum ובו מצויים המספרים. תודה לכל העוזרים, שוב תודה רבה!
 
למעלה