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 |
一次就过了。不难,贴个代码参考一下:#include"stdio.h" #include"string.h" int getmin(char a[]) { int i,j=0; char c='z';/*将c的值置最大(小写z就行了)*/ for(i=0;i<strlen(a);i++) if(c>a[i]) { c=a[i]; j=i; } a[j]='z';/*去掉这个最小值,便于下次取次最小值*/ return j; } int main() { char keyword[50]; while(scanf("%s",&keyword)&&strcmp(keyword,"THEEND")) { char a[101],b[101]; int i,j,k,m=0,n; scanf("%s",&a); /*获取结果*/ for(i=0;i<strlen(keyword);i++) { j=getmin(keyword); n=j; for(k=0;k<strlen(a)/strlen(keyword);k++) { b[n]=a[m]; m++; n+=strlen(keyword); } } for(i=0;i<strlen(a);i++)//输出 printf("%c",b[i]); printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator