[编程题]串
  • 热度指数:148 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 256M,其他语言512M
  • 算法知识视频讲解

给出个只包含小写字母的字符串,将长度为奇数的字符串按顺序拼接后输出。


输入描述:
第一行输入一个整数
接下来行,每行一个字符串。
字符串的长度总和不超过


输出描述:
输出一行一个字符串,表示答案。
示例1

输入

3
abc
ab
a

输出

abca

说明

"abc","a"长度为奇数,按顺序拼接后为"abca"
示例2

输入

4
aaaa
bsd
we
lzwrue

输出

bsd
#include <iostream>
#include <string>
using namespace std;

int main()
{
    int n;
    cin >> n;
    string s;
    string ss = "";//存储最终结果
    for(int i = 1; i <= n; i++)
    {
        cin >> s;
        if(s.length() % 2 != 0)
        {
            ss = ss + s;
        }
    }
    cout << ss << endl;
}
发表于 2025-08-15 21:17:20 回复(0)