2
www.dotcpp.com DOTCPP
A C M
D O T CPP
www.dotcpp.com DOTCPP
A C M
D
O
T
CPP
题意:
对于前n行,直接输出
对于n行以后,用空格或者空行进行分开输出
思路:
gets()的用法:可接受回车键之前输入的所有字符,并用‘\0‘替代‘\n‘回车键不会留在缓冲区内
puts()的用法:在输出字符串时会将‘\0‘自动转换为‘\n‘进行输出,输出完字符串后会自动换行
所有gets()和puts()用来接受前n行的指令
代码:
#include <stdio.h>
int main()
{
int p;
scanf("%d",&p);
getchar();
char s[1002];
while(p--)
{
gets(s);
puts(s);
printf("\n");
}
while(scanf("%s",s)!=EOF)
{
printf("%s",s);
printf("\n\n");
}
return 0;
}
反思:
EOF代表文件结尾标志
原文:https://www.cnblogs.com/redzzy/p/13637538.html