int main()
{
char s
while((s=getchar())!='!')
{
if(s>='a'&&s<'z')
++s
else if(s=='z')
s='a'
else if(s>='A'&&s<'Z')
++s
else if(s=='Z')
s='A'
printf("%c"陵尘,s)
}
printf("!")
}
调了半天,楼主真是太粗心了!middle1[]应该这锋春样声明渣源:char middle1[]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','如基态U','V','W','X','Y','Z'}
最后输出start的时候要注意控制长度,改个for循环就好了!
#include<stdio.h>
#include<string.h>
int main(void)
{
int i,j,length,n
char temp
char middle2[27]
char start[201],finish[201]
char middle1[]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}
gets(middle2)
gets(finish)
scanf("%d",&n)
length=strlen(finish)
for(i=0i<25i++)
{
for(j=i+1j<26j++)
{
if(middle2[i]>middle2[j])
{
temp=middle2[i]
middle2[i]=middle2[j]
middle2[j]=temp
temp=middle1[i]
middle1[i]=middle1[j]
middle1[j]=temp
}
}
}
for(i=1i<=ni++)
{
for(j=0j<lengthj++)
{
if(finish[j]==' ')
{
start[j]=' '
}
else
{
start[j]=middle1[finish[j]-'A']
}
}
}
for( i = 0i <length++i)
printf("%c",start[i])
printf("\n")
return 0
}
/*
ABCDEFGHIJKLMNOPQRSTUVWXYZ
*/
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)