ysxq @ 2023-07-13 15:04:16
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main() {
int n;
char ch ;
scanf("%d", &n);
getchar();
while ((ch = getchar()) != '\n') {
putchar( (ch - 97 + n)%26+97);
}
}
by ysxq @ 2023-07-13 15:05:23
scanf是为了把换行符清空,避免干扰下面的getchar
by Aybbl_xc @ 2023-07-13 15:09:10
我看了一下第一个样例也是没问题的
by 编码落寞 @ 2023-07-13 15:30:43
@TiAm0
换行符问题
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main() {
int n;
char ch ;
scanf("%d", &n);
getchar(); getchar();
while ((ch = getchar()) != EOF) {
putchar( (ch - 97 + n)%26+97);
}
}
by ysxq @ 2023-07-13 16:02:48
@编码落寞 第二个getchar有什么作用
by 编码落寞 @ 2023-07-13 16:25:40
@TiAm0
windows中要回车符+换行符("\r\n")才会回车+换行
网上找的
by ysxq @ 2023-07-13 16:28:49
@编码落寞 感谢