Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求助2295Orz

Posted by xuchang0731 at 2011-05-22 05:52:36
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		char in[270];
		cin>>in;
		char temp[270]="+";
		strcat(temp,in);
		char s[500];
		int i=0,j=0;
		while(temp[i]){
			if( (temp[i]=='+'||temp[i]=='-'||temp[i]=='=') &&temp[i+1]=='x'){
				s[j++]=temp[i++];
				s[j++]='1';
			}
			else{
				s[j++]=temp[i++];
			}
			
		}
		s[j]='\0';
		
		int ctx=0,ctn=0;
		char num[10];
		i=0;j=0;
		while(s[i]!='='){
			if(s[i]=='+'||s[i]=='x'){
				i++;
				continue;
			}
			num[j++]=s[i];
			if( ! isdigit( s[i+1] ) ){
				num[j]='\0';
				if( s[i+1]=='x' ){
					ctx+=atoi(num);
				}
				else{
					ctn+=atoi(num);
				}
				j=0;
			}
			i++;
		}
		i++;
		while(s[i]!='\0'){
			if(s[i]=='+'||s[i]=='x'){
				i++;
				continue;
			}
			num[j++]=s[i];
			if( ! isdigit( s[i+1] ) ){
				num[j]='\0';
				if( s[i+1]=='x' ){
					ctx-=atoi(num);
				}
				else{
					ctn-=atoi(num);
				}
				j=0;
			}
			i++;
		}
		if(ctx==0&&ctn!=0){
			cout<<"IMPOSSIBLE"<<endl;
		}
		else{
			if(ctx==0&&ctn==0){
				cout<<"IDENTITY"<<endl;
			}
			else{
				cout<< floor (float(-ctn)/ctx)<<endl;
			}
		}
		
	}
	return 0;
}
求一组能让我发现错误的测试数据。。。
自己测完全木有问题啊。。。。。。。。
求大牛指点Orz

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator