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

又是说答案错误了!是怎么回事啊,我想了很多遍了哦。能否给我多些测试用例。麻烦了。各位高手!我真的投降了!

Posted by plumage at 2005-05-18 23:33:49 on Problem 1047
#include<iostream.h>
#include<fstream.h>

#define MaxLength 61
fstream fin("in.txt",ios::in);
char In[MaxLength];
int input[MaxLength],result[MaxLength];
bool cyclic=false;
int length;
int temp;

/////////////////end(bool r)
void end(bool r)
{
	if(!r)
		cout<<In<<" is not cyclic"<<endl;
	else
		cout<<In<<" is cyclic"<<endl;
}
/////////////////judge()
bool judge()
{
/*	
	int j;

	cout<<"input:";
	for(j=length-1;j>=0;j--)
		cout<<input[j];
	cout<<endl;
	cout<<"result:";
	for(j=length-1;j>=0;j--)
		cout<<result[j];
	cout<<endl;
*/
	int r1=0,i1=0,t=0;
	for(t=0;t<length;t++)
	{
		if(result[0]==input[t])
		{
			r1=1;
			i1=t+1;
			i1%=length;
			while(result[r1]==input[i1])
			{
				if(r1==(length-1))
				{
					return true;
				}
				r1++;
				i1++;
				i1%=length;
			}
		}
	}
	return false;
}


/////////////////
void main()
{

//	fin>>In;
	cin>>In;
// 	cout<<In<<endl;
	int i,j;
	for(i=0;In[i]!='\0';i++)
		;
 
	length=i;//the number of digit of the data inputed
//	cout<<(int)'0'<<endl;
	for(j=0;j<length;j++)
	{
		i--;		
		input[j]=In[i]-48;
//		cout<<input[j]; 
		
	}
	input[j]='\0';
//	cout<<endl;
	for(i=length;i>=2;i--)
	{
 
		result[0]=0;
//		cout<<"i:"<<i<<endl;

		for(j=0;j<length;j++)
		{
			temp=result[j]+input[j]*i;
			result[j]=temp%10;
			result[j+1]=temp/10;
		//	cout<<result[j];
		}
		//cout<<endl;

		if(result[j]!=0)
		{
			cout<<"here?"<<endl;
			end(false);
			return;
		}
/*
		for(j=length-1;j>=0;j--)
			cout<<result[j];
		cout<<endl;
*/
	//	result[j]='\0';
		cyclic=judge();
		
		if(!cyclic)
		{
		//	cout<<"here?"<<endl;
			end(false);
			return;
		}
	}
	end(true);
	
}

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