hesetone


私信TA

用户名:hesetone

访问量:1650

签 名:

等  级
排  名 25873
经  验 531
参赛次数 2
文章发表 2
年  龄 0
在职情况 学生
学  校 Jiangxi University Of Science
专  业

  自我简介:

TA的其他文章

解题思路:

虽然一遍就过,但还是觉得这个题目有点叙述不清楚,反正设置一个计数器cnt,计算输入字符串的数量,超过N的便采取特殊处理,还有,输入n之后记得getchar(),其他的没什么了。



注意事项:





参考代码:

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<time.h>
#include<set>
#include<deque>
#include<stack>
#include<cmath>
#include<string>
#include<cstdlib>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    char str[1001];
    scanf("%d",&n);
    getchar();
    int cnt=0;
    while(scanf("%[^\n]%*c",&str)!=EOF) {
        if(cnt<n)  {
            if(cnt==0) printf("%s\n",str);
            else printf("\n%s\n",str);
        } else {
            printf("\n");
            for(int i=0; i<strlen(str); i++) {
                if(str[i]==' ') printf("\n\n");
                else printf("%c",str[i]);
            }
            printf("\n");
        }
        cnt++;
    }
    return 0;
}



 

0.0分

0 人评分

  评论区