[ABC427A]ABC -> AC题解
Time Limit: 2 sec / Memory Limit: 1024 MiB
Score : 100 points
Problem Statement
You are given a string S consisting of uppercase English letters. Here, the length of S is odd.
Print the string obtained by deleting the middle character of S. The middle character of S is the 2L+1-th character of S, where L is the length of S.
有道 翻译
问题陈述
您将得到一个由大写英文字母组成的字符串 S 。这里 S 的长度是奇数。
打印删除 S 中间字符后得到的字符串。 S 的中间字符是 S 的第1个字符 2L+1 ,其中 L 是 S 的长度。
Constraints
- S is a string consisting of uppercase English letters.
- The length of S is an odd number between 3 and 9, inclusive.
有道 翻译
# #约束
— S 是由英文大写字母组成的字符串。
— S 的长度为 3 到 9 之间的奇数(含整数)。
Input
The input is given from Standard Input in the following format:
S
有道 翻译
# #输入
输入来自标准输入,格式如下:
S
Output
Print the string as instructed in the problem statement.
有道 翻译
# #输出
按照问题语句中的指示打印字符串。
Sample Input 1
Copy
ABCDE
Sample Output 1
Copy
ABDE
The middle character of ABCDE is the 3-rd character C, so print ABDE.
有道 翻译
###输出示例
ABDE
‘ ABCDE ’的中间字符是 3 -rd字符‘ C ’,因此打印‘ ABDE ’。
Sample Input 2
Copy
OOO
Sample Output 2
Copy
OO
有道 翻译
###示例输出
OO
Sample Input 3
Copy
ATCODER
Sample Output 3
Copy
ATCDER
有道 翻译
###输出示例
ATCDER
思路
暴力。
代码见下
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
cin>>s;
for(int i=0;i<s.size();i++){
if(i+1!=(s.size()+1)/2){
cout<<s[i];
}
}
cout<<endl;
return 0;
}

浙公网安备 33010602011771号