Description:
字符串的输入输出处理。
Input:
第一行是一个正整数N,最大为100。
之后输入多行字符串(行数大于N), 每一行字符串可能含有空格,且字符数不超过1000。
Output:
对于前N行字符串,按原样输出;
对于其余的字符串以空格符为分割依次按行输出。
注意:每行输出之间均要输出一个空行。
Sample Input:
2
www.njupt.edu.cn NUPT
A C M
N U P Ter
Sample Output:
www.njupt.edu.cn NUPT
A C M
N
U
P
Ter
Note:
对于输入输出仍有困惑的同学请仔细阅读以下内容:
在ACM竞赛中,对于数据的读入,一般有以下四种情况:
一、四种基本输入形式:
1. 单组输入数据
示例:整数求和
C语言:#include
int main()
{
int a,b;
scanf("%d %d",&a, &b);
printf("%d\n",a+b);
}
C++:#include
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<
return 0;
}
注意:输入前无需也不要输出任何提示信息。
2. 多组输入数据,且不说明多少组,直到读至输入文件末尾为止
示例:A + B Problem (1)
C语言:#include
int main()
{
int a,b;
while(scanf("%d %d",&a,&b) != EOF)
printf("%d\n",a+b);
return 0;
}
说明:scanf函数返回值就是读出的变量个数,如:scanf( “%d %d”, &a, &b );如果只有输入了一个整数,返回值是1,如果输入了两个,返回值是2,如果一个都没有,则返回值是EOF。EOF是一个预定义的常量,等于-1
C++:#include
using namespace std;
int main()
{
int a,b;
while(cin>>a>>b)
cout<