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 jjh at 2005-11-12 21:57:05 on Problem 2712
#include<iostream>
using namespace std;

bool isdigit(char c)
{
    if(c>='0'&&c<='9')
        return 1;
    return 0;
}

bool isletter(char c)
{
    if(c>='A'&&c<='Z'||c>='a'&&c<='z')
        return 1;
    return 0;
}

bool isupper(char c)
{
    if(c>='A'&&c<='Z')
        return 1;
    return 0;
}

bool ismark(char c)
{
    if(!isletter(c)&&!isdigit(c)&&c!=' ')
        return 1;
    return 0;
}


bool un(char c)
{
    if(c!='A'&&c!='a'&&c!='I')
        return 1;
    return 0;
}


int main()
{
	char s[85];
	int i,l,flag;
	while(1)
	{
		gets(s);
		if(s[0]=='#')
			break;
		for(l=0;s[l]!='\0';l++);
		flag=1;
		for(i=0;i<l-1&&flag==1;i++)
		{
			if(isupper(s[i])&&isupper(s[i+1]))
				flag=0;
			else if(isletter(s[i])&&isdigit(s[i+1])||
					isletter(s[i+1])&&isdigit(s[i]))
					flag=0;
			else if(i>=1&&i<=(l-3)&&s[i]==' '&&s[i+2]==' '&&un(s[i+1]))
				flag=0;
			else if(i==(l-2)&&s[i]==' '&&un(s[i+1]))
				flag=0;
			else if(i==0&&s[i+1]==' '&&un(s[i]))
				flag=0;
			
			else if(ismark(s[i])&&ismark(s[i+1])&&s[i]!='"'&&s[i+1]!='"')
				flag=0;
		}

		if(flag==0)
			printf("suspicious\n");
		else printf("OK\n");
	}
	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