1# include<iostream>2# include<string>3# include<iomanip>4# include<cmath>5 using namespacestd;6 intA=0, b=0, c=0;7 voidGetpar (stringSintflag)8 {9 if(s=="0")return ;Ten intL=s.size (); One BOOLneg=true; A intI=0; - for(i=0; i<l;i++) - { the intsum=0; - if(s[i]=='-') {neg=false; i++;} - Else if(s[i]=='+') {neg=true; i++;} - while(s[i]>='0'&& s[i]<='9') + { -sum=sum*Ten+s[i]-'0'; +i++; A } at if(sum==0) {sum=1;} - if(!neg) sum=-1*sum; - if(i==l) - { - if(flag) c=c-sum; - Elsec=c+sum; in } - Else if(s[i]=='x') to { + if(i+1<l && s[i+1]=='^') - { the if(flag) a=a-sum; * Elsea=a+sum; $ //a=a+flag?-1*sum:sum;Panax Notoginsengi=i+2; - } the Else { + //b=b+flag? -1*sum:sum; A if(flag) b=b-sum; the Elseb=b+sum; + } - } $ } $ } - intMain () { - strings; the while(cin>>s) { -A=b=c=0;Wuyi intPos=s.find ('='); the intL=s.size (); - stringS1=S.SUBSTR (0, POS); Wu stringS2=s.substr (pos+1, L-1); -Getpar (S1,0); AboutGetpar (S2,1); $ Doubledot=b*b-4*a*C; - //cout<<a<< "" <<b<< "" <<c<<endl; - if(dot<0) cout<<"No Solution"<<Endl; - Else A { + Doubleb1= (-B-SQRT (dot))/(2.0*a); the Doubleb2= (-B+SQRT (dot))/(2.0*a); - if(b1>B2) ${cout<<fixed<<setprecision (2) <<b2<<" "<<b1<<Endl;} the Elsecout<<fixed<<setprecision (2) <<b1<<" "<<b2<<Endl; the } the } the return 0; -}
I don't know, fault, mark it.
Nine degrees [1103] two-time equation calculator