#include
#include
using namespace std;
int main ()
{
char ch,val[1000];
int num,n,j=0,z,v1[1000]={0},v2[1000]={0};
while(cin>>n)
{
for(int i=0;i {
cin.get(ch);
while(ch!=10)
{
cout<<11< if(isdigit(ch))
{cin.putback(ch);
cin>>num;
cin.get(ch);
val[j]=ch;
if(val[j]=='=')
z=j;
if(val[j-1]=='+')
{if(val[j]=='x')
v1[j]=num;
else
v2[j]=num;
j++;}
else if(val[j-1]=='-')
{if(val[j]=='x')
v1[j]=-num;
else
v2[j]=-num;
j++;}
}
else
{
if(ch=='x')
v1[j]=1;
else
val[j]=ch;
j++;}
}
while(z<1000)
{v1[z]=-v1[z];
v2[z]=-v2[z];}
for(int x=0;x<1000;x++)
v1[x+1]=v1[x]+v1[x+1];
int X=v1[999];
for(int c=0;c<1000;c++)
v2[c+1]=v2[c]+v2[c+1];
int C=v2[999];
if(X==0&&C==0)
cout<<"IDENTITY"< else if(X==0&&C!=0)
cout<<"IMPOSSIBLE"< else
{int out;
out=-(C/X);
if(out<0&&C%X!=0)
cout< else
cout<
}
}
}
}
帮忙看看这个代码~~~
--------------------next---------------------
阅读(1057) | 评论(0) | 转发(0) |