复平面ljz @ 2021-02-07 15:45:22
#include<stdio.h>
#include<stdlib.h>
struct zimu
{
char c;
struct zimu *next;
};
int main(void)
{
int i,n,j;
scanf("%d", &n);
getchar();
char c0 = 'a';
struct zimu *p1;
struct zimu *p2;
struct zimu *head;
p1 = (struct zimu *)malloc(sizeof(struct zimu));
head = p1;
for (i = 1;i <= 26;i++)
{
p1->c = c0;
c0++;
if (i == 26)
{
p1->next = head;
break;
}
p2 = p1;
p1 = (struct zimu*)malloc(sizeof(struct zimu));
p2->next = p1;
}
char a[50];
for (i = 0;i <= 49;i++)a[i] = '\0';
c0 = getchar();
for (i = 0;c0 != '\n';i++)
{
a[i] = c0;
c0 = getchar();
}
struct zimu *p;
for (i = 0;a[i] != '\0';i++)
{
for (p = head;p->c != a[i];p = p->next);
for (j = 1;j <= n;j++)p = p->next;
a[i] = p->c;
}
for (i = 0;a[i] != '\0';i++)printf("%c", a[i]);
return 0;
}
这个为什么全部WA?
by _caiji_ @ 2021-02-07 15:49:36
getchar()
getchar(),getchar()
by 复平面ljz @ 2021-02-07 23:57:54
@caijianhong 什么意思,指所有的getchar()吗?本萌新没有看懂
by FireWolf @ 2021-02-28 19:45:11
@复平面ljz 洛谷评测机默认敲一下回车会输入两个字符"\r\n",所以要写两个getchar()来清除第一行末尾的空白符