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 top1 at 2006-04-11 11:32:50 on Problem 1537
#include<iostream.h>
#include<string.h>
int main()
{
	char a[255];
	int i,n,j,m,judge;
	cin>>a;
	while ( a[0]!='*' )
	{   
		judge=0;i=0;j=0;
		n=strlen(a);
        if ( (a[0]!='+'&&a[0]!='-')&&(a[0]<'0'||a[0]>'9') )
			goto found;
		for ( m=0 ; m<n ; m++ )
		{
			if ( a[m] == '.' )
				i=m;
			if ( a[m] == 'e' || a[m] == 'E')
				j=m;
		}
		if ( i==0 )
            goto found;
		for ( m=1 ; m<i ;m++ )
			if ( a[m]<'0' || a[m]>'9' )
				goto found;
            if ( a[m+1]<'0'||a[m+1]>'9' )
				goto found;
			if ( j!=0 )
			{
				for ( i++ ; i<j ;i++)
		         	if ( a[i]<'0' || a[i]>'9' )
				        goto found;
			    if ( (a[j+1]!='+'&&a[j+1]!='-')&&(a[j+1]<'0'||a[j+1]>'9')  )
	     	     	goto found;
				    j+=2;
		        for ( ; j<n ;j++)
					if ( a[j]<'0' || a[j]>'9' )
						goto found;
			}
			judge = 1;
found:
		if ( judge ==1 )
			cout<<a<<" is legal."<<endl;
		else 
			cout<<a<<" is illegal."<<endl;
		cin>>a;
	}
	return 0;
}

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