字符串的输入输出处理

Time Limit: 1 Sec Memory Limit: 64 MB Submit: 333 Solved: 71 [][][]

Description

字符串的输入输出处理。 字符串的输入输出处理。

Input

第一行是一个正整数N,最大为100。之后是多行字符串(行数大于N), 每一行字符串可能含有空格,字符数不超过1000。 第一行是一个正整数N,最大为100。之后是多行字符串(行数大于N), 每一行字符串可能含有空格,字符数不超过1000。

Output

先将输入中的前N行字符串(可能含有空格)原样输出,再将余下的字符串(不含有空格)以空格或回车分割依次按行输出。每行输出之间输出一个空行。 先将输入中的前N行字符串(可能含有空格)原样输出,再将余下的字符串(不含有空格)以空格或回车分割依次按行输出。每行输出之间输出一个空行。

Sample Input

2
www.njupt.edu.cn NUPT
A C M
N U P Ter
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
#include <stdio.h>
#include <string.h>
int main()
{
    int n,i=0;
    char a[100000];
    scanf("%d",&n);
    getchar();
    while(gets(a)!=NULL)
    {
        i++;
        if(i<=n)
       {
           puts(a);
           puts("");
       }

       if(i>n)
       {
           int length=strlen(a);
           for(int j=0;j<length;j++)
           {

               if(a[j]== ||a[j]==
)
               {
                   printf("

");
               }
               else
                printf("%c",a[j]);
           }
           printf("

");
       }

    }
    return 0;
}
#include #include int main() { int n,i=0; char a[100000]; scanf("%d",&n); getchar(); while(gets(a)!=NULL) { i++; if(i<=n) { puts(a); puts(""); } if(i>n) { int length=strlen(a); for(int j=0;j
www.njupt.edu.cn NUPT A C M N U P Ter #include #include int main() { int n,i=0; char a[100000]; scanf("%d",&n); getchar(); while(gets(a)!=NULL) { i++; if(i<=n) { puts(a); puts(""); } if(i>n) { int length=strlen(a); for(int j=0;j
Time Limit: 1 Sec Memory Limit: 64 MB Submit: 333 Solved: 71 [][][] 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 #include #include int main() { int n,i=0; char a[100000]; scanf("%d",&n); getchar(); while(gets(a)!=NULL) { i++; if(i<=n) { puts(a); puts(""); } if(i>n) { int length=strlen(a); for(int j=0;j
经验分享 程序员 微信小程序 职场和发展