Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我也不知道为啥output limited。why#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> int n; int isVowel(char x) { if(x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u'||x == 'y') return 1; else return 0; } int isRight(char * str, int type) { int i, tar, num = 0; int len = strlen(str); if(type == 1 ) tar = 5; else tar = 7; for(i = 0; i<len; i++) { if(isVowel(str[i])) { num++; //printf("i = %d, str[i] = %c\n", i, str[i]); while(isVowel(str[i])) { i++; } } } // printf("str = %s, type = %d, num = %d\n", str, type, num); return num; } int main() { int i, j, k, len; int a, b, c; char *sep="//"; char *p; char temp[1000]; char str[500]; while( 1 ) { memset(temp, 0, sizeof(temp)); a = 0, b = 0, c = 0; fgets(temp, 500, stdin); len = strlen(temp); temp[len-1] = '\0'; len--; if(len == 0) continue; //printf("temp = %s, len = %d\n", temp, len); //if( 0 == strcmp(temp, "e/o/i")) if(temp[0] == 'e' && temp[1] == '/' && temp[2] == 'o' &&temp[3] == '/' && temp[4] == 'i') { break; } p = strtok(temp, sep); memset(str, 0, sizeof(str)); sprintf(str, "%s", p); // printf("str = %s\n", str); a = isRight(str, 1 ); p = strtok(NULL, sep); memset(str, 0, sizeof(str)); sprintf(str, "%s", p); // printf("str = %s\n", str); b = isRight(str, 2 ); p = strtok(NULL, sep); memset(str, 0, sizeof(str)); sprintf(str, "%s", p); // printf("str = %s\n", str); c = isRight(str, 1 ); if(a != 5) { printf("1\n"); continue; } if(b != 7) { printf("2\n"); continue; } if(c != 5) { printf("3\n"); continue; } printf("Y\n"); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator