PersonalCorpus 版 (精华区)
寄信人: sino (茶水)
标 题: 492
发信站: 哈工大紫丁香 (2002年06月16日17:45:04 星期天)
来 源: 202.118.239.224
Your C++ program has solved Ok the problem 492 (Pig-Latin)
in 0.120 seconds using as much as 400 kbytes of virtual memory.
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <ctype.h>
void main()
{
#ifndef ONLINE_JUDGE
freopen("c:\\uva\\input492.txt","r",stdin);
freopen("c:\\uva\\output492.txt","w",stdout);
#endif
char ch;
char now[5001];
int i,j,k;
k=0;
while (1) {
ch=getchar();
if (isalpha(ch)) {
now[k]=ch;
k++;
continue;
} else if (k>0){
now[k]=0; k=0;
ch=now[0];
if
((ch=='a')||(ch=='e')||(ch=='i')||(ch=='o')||(ch=='u')||
(ch=='A')||(ch=='E')||(ch=='I')||(ch=='O')||(ch=='U'))
{
strcat(now,"ay");
printf("%s",now);
}else {
i=strlen(now);
now[i]=now[0];
now[i+1]='a';
now[i+2]='y';
now[i+3]=0;
printf("%s",now+1);
}
}
if (ch!=EOF) putchar(ch); else break;
}
}
--
SecureNetTerm can be dowloaded to all countries except
Cuba, Iran, Iraq, Libya, North Korea, Sudan and Syria.
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.239.224]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.997毫秒