AsobiAsobase @ 2018-12-11 19:54:26
int main() { char a[1000]; int i,j,n; scanf("%d",&n); { getchar(); gets(a); if(n>26) { n=n%26; } for(i=0;a[i];i++) { a[i]+=n; if(a[i]>'z') { a[i]-=122; a[i]+=96; } } puts(a); } return 0; }
by ZERORUSH @ 2018-12-11 19:57:36
希望更丰富的展现?使用Markdown
by AsobiAsobase @ 2018-12-11 19:58:47
#include<stdio.h>
int main()
{
char a[1000];
int i,j,n;
scanf("%d",&n);
{
getchar();
gets(a);
if(n>26)
{
n=n%26;
}
for(i=0;a[i];i++)
{
a[i]+=n;
if(a[i]>'z')
{
a[i]-=122;
a[i]+=96;
}
}
puts(a);
}
return 0;
}
by AsobiAsobase @ 2018-12-11 20:03:32
#include<stdio.h>
int main()
{
char a[1000];
int i,j,n;
scanf("%d",&n);
getchar();
gets(a);
if(n>26)
{
n=n%26;
}
for(i=0;a[i];i++)
{
a[i]+=n;
if(a[i]>'z')
{
a[i]-=122;
a[i]+=96;
}
}
puts(a);
return 0;
}
by _ @ 2018-12-11 20:15:39
#include<stdio.h>
int main()
{
char a[1000];
int i,j,n;
scanf("%d",&n);
getchar();
gets(a);
if(n>26)
{
n=n%26;
}
for(i=0;a[i];i++)
{
a[i]+=n;
if(a[i]>'z')
{
a[i]-=122;
a[i]+=96;
}
putchar(a[i]);
}
return 0;
}
似乎puts会加一个换行
by AsobiAsobase @ 2018-12-11 20:23:14
@jyy666 好的谢谢,我换了一个输入方法了
#include<stdio.h>
#include<string.h>
int main()
{
char a[103];
int i,j,n;
scanf("%d%s",&n,a);
j=strlen(a);
if(n>26)
{
n=n%26;
}
for(i=0;i<j;i++)
{
a[i]+=n;
if(a[i]>'z')
{
a[i]-=122;
a[i]+=96;
}
}
for(i=0;i<j;i++)
{
printf("%c",a[i]);
}
return 0;
}
by 初墨 @ 2018-12-11 20:40:10
这题很水啊