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

怎么老是Output Limit Exceed?是有什么没考虑到吗?

Posted by hz02ruc at 2003-11-14 13:55:48 on Problem 1566
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#define N 210
char buf[N],a[N],b[N],c[N];
int is_vowel(char ch)
{
 return (ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='y');
}
int is_correct(char buf[N])
{
  int len=strlen(buf);
  for(int i=0;i<len-1;i++)
  {
	  if(!islower(buf[i])&&buf[i]!=' '&&buf[i]!=47)
	    return 0;
  }
  return 1;
}
int num(char *p)
{
  int l=strlen(p),count=0,i=0;
  while(i<l)
  {
	  if(is_vowel(p[i]))
	  {
		 while(is_vowel(p[i])&&i<l)  
		  i++;
    	          count++;
	  }
	  else
		  i++;
  }
  return count;
}      
void review()
{
   int i=0,j=0,aa=0,bb=0,cc=0;
   while(buf[i]!=47)
     a[j++]=buf[i++];
   a[j]='\0';
   i++; 
   j=0;
   while(buf[i]!=47)
     b[j++]=buf[i++];
   b[j]='\0';
   i++;j=0;
   while(buf[i]!='\n')
     c[j++]=buf[i++];
   c[j]='\0'; 
   aa=num(a);bb=num(b);cc=num(c);
   if(!is_correct(buf))
   {  
	   if(aa!=5) {printf("1");return;}
            if(bb!=7) {printf("2");return;}
	   if(cc!=5) {printf("3");return;}
   }
   if(aa!=5) printf("1");
   else if(bb!=7) printf("2");
   else if(cc!=5) printf("3");
   else printf("Y");
   return;
}
int main()
{
   fgets(buf,N,stdin);
   while(strncmp(buf,"e/o/i\0",strlen(buf)-1)!=0)
   {
	   review();printf("\n");fflush(stdin);
	   fgets(buf,N,stdin);
   }
   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