Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2342328
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 18:01:32

#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---------------------

阅读(1051) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~