POJ 3617 Best Cow Line
程序员文章站
2022-07-04 20:11:01
...
-
Source Code
#include<iostream> using namespace std; int main() { int n; while (cin >> n) { char a[2005]; for (int i = 0; i < n; i++) cin >> a[i]; int st = 0, back = n - 1; int t = 0; while (st <= back) { bool b = 0; for (int i = 0; st + i < back; i++) { if (a[st + i] > a[back - i]) { b = 1; break; } else if (a[st + i] < a[back - i]) break; } if ((t % 80 == 0)&&t!=0) cout << endl; t++; if (b == 1) cout << a[back--]; else cout << a[st++]; } cout << endl; } return 0; }