OddString

问题 D: OddString
时间限制: 1 Sec 内存限制: 128 MB
提交: 374 解决: 218
[提交] [状态] [讨论版] [命题人:admin]
题目描述

You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.

Constraints
Each character in s is a lowercase English letter.
1≤|s|≤105

输入

The input is given from Standard Input in the following format:
s

输出

Print the string obtained by concatenating all the characters in the odd-numbered positions.

样例输入

atcoder

样例输出

acdr

#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    char s[100005],str[100005];
    scanf("%s",s);
    int len=strlen(s);
    int cnt=0;
    for(int i=0;i<len;i++)
    {
        if(i%2==0)
            str[cnt++]=s[i];
    }
    printf("%s\n",str);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/a17865569022/article/details/81274280