| ||||||||||
| 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 | |||||||||
帮我看H题---表达式错误!!!!!!!!!!!!!!哪里错呀!!!!!!!!!!!!!In Reply To:POJ的Contest真是越来越精彩了,居然有人13分钟就能AC 5题,pfpf!! Posted by:Judge at 2004-10-26 18:19:37 #include<stdio.h>
#include<string.h>
int main()
{
int i,j,k,n,L;
char ch[100],st[100],g[260],c;
int f[260];
while(gets(ch)!=NULL)
{
L=strlen(ch);
while(ch[L-1]==' ') { ch[L-1]='\0'; L--;}
L=strlen(ch);
k=0;
for(i=0;i<=250;i++) f[i]=g[i]=0;
g['A']=g['E']=g['I']=g['O']=g['U']=1;
k=-1;
for(i=0;i<L;i++)
{
if(g[ch[i]]) continue;
if(ch[i]>='A'&&ch[i]<='Z')
{
if(f[ch[i]]==1) continue;
f[ch[i]]=1;
k++; st[k]=ch[i];
}
else
{
if(k>=0)
{
if(ch[i]==' '&&st[k]==' ') continue;
if(ch[i]==','||ch[i]=='.'||ch[i]=='?')
while(st[k]==' ') k--;
}
if(ch[i]==' '&&(i==0||i==L-1)) continue;
k++;
st[k]=ch[i]; //printf("_=%c",ch[i]);
}
}//for L
c=st[k];// printf("c=%c\n",c);
while(st[k-1]==' ') { k--;}
st[k]=c;
st[k+1]='\0';
printf("%s\n",st);
}//while
return 0;
}
/*
Sample Input
NOW IS THE TIME FOR ALL GOOD MEN TO COME TO THE AID OF THEIR COUNTRY.
Sample Output
NW S TH M FR L GD C Y.
MADAM_I_SAY_I_AM_ADAM__
MD_SY
*/
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator