当前位置: 代码迷 >> C语言 >> [求助]zju1799
  详细解决方案

[求助]zju1799

热度:268   发布时间:2007-05-18 19:10:01.0
[求助]zju1799

这是中文题目:http://bbs.haizhong.edu.cn/cgi-bin/topic.cgi?forum=19&topic=22
这是zju提交的地方:http://acm.zju.edu.cn/show_problem.php?pid=1799
这是我写的程序:
#include <stdio.h>
main()
{
int p,q,i,j,k,len,f,lon,m;
char a[100][100],b[100][100],c[100][100],d[100],e[100];
while(1)
{
gets(d);
if(strcmp(d,"THEEND")==0)break;
len=strlen(d);
f=0;
gets(e);
lon=strlen(e);
m=0;
for(i=0;i<len;i++)
{
for(j=0;j<lon/len;j++)
a[i][j]=e[m++];
a[i][j+1]='\0';
}

for(p=0;p<len-1;p++)
{
for(q=0;q<len-p-1;q++)
if(d[q]>d[q+1])
{
strcpy(b[p],a[q]);
strcpy(a[q],a[q+1]);
strcpy(a[q+1],b[p]);
}
}

for(i=0;i<lon/len;i++)
{
for(j=0;j<len;j++)
printf("%c",a[j][i]);
printf("\n");
}

}
}
我认为我排序错了但检查不出来哪位大虾帮忙解答一下。

搜索更多相关的解决方案: 中文  blank  include  target  

----------------解决方案--------------------------------------------------------

#include<stdio.h>
#include<stdio.h>
main()
{
int a,b,i,j,c[1000],d,e,f,r,t,k,g,n[1000],y;
char q[1000],p[1000],o[1000],w;
while(scanf("%s",q)!=EOF)
{
if(strcmp(q,"THEEND")==0)break;
getchar();
a=strlen(q);
g=0;
for(i=0;i<a;i++)
{
w=q[i];
for(j=a-1;j>=0;j--)
{
if(w>=q[j]){b=j;w=q[j];}
}
q[b]='{';
c[g]=b;
n[g]=g;
g++;
}
for(i=0;i<=g-1;i++)
{ for(j=0;j<g-1-i;j++)
{ if(c[j]>c[j+1])
{
y=c[j];
c[j]=c[j+1];
c[j+1]=y;

y=n[j];
n[j]=n[j+1];
n[j+1]=y;
}
}
}
gets(p);
d=strlen(p);
f=d/a;

e=0;
for(j=0;j<f;j++)
{
r=0;
for(i=0;i<d;i++) {if(i%f==e) {o[r]=p[i];r++;}}
e++;
for(t=0;t<a;t++) printf("%c",o[n[t]]);
printf("\n");
}
}
}
我的通过了的


----------------解决方案--------------------------------------------------------
我只想修改自己的!!!
----------------解决方案--------------------------------------------------------
  相关解决方案