'commit'
This commit is contained in:
37
TangDou/AcWing/TiaoZhanChengXuSheJi/POJ3617.cpp
Normal file
37
TangDou/AcWing/TiaoZhanChengXuSheJi/POJ3617.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
const int N = 2010;
|
||||
char s[N];
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
for (int i = 0; i < n; i++) cin >> s[i];
|
||||
|
||||
int a = 0, b = n - 1, idx = 0;
|
||||
|
||||
while (a <= b) {
|
||||
bool left = false;
|
||||
for (int i = 0; a + i <= b; i++) { // 若首位相等则比较下一个
|
||||
if (s[a + i] < s[b - i]) {
|
||||
left = true;
|
||||
break;
|
||||
}
|
||||
if (s[a + i] > s[b - i]) {
|
||||
left = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (left)
|
||||
putchar(s[a++]);
|
||||
else
|
||||
putchar(s[b--]);
|
||||
idx++;
|
||||
|
||||
if (idx == 80) {
|
||||
idx = 0;
|
||||
puts("");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user