如果输入的字符串长度为n,那么程序中的swap操作最多执行()次
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
char str[1005];
int main() {
scanf("%s", str);
int len = strlen(str);
int l = 0, r = len - 1, tmp;
while(l < r) {
while (str[l] % 2 == 0 && l < r) {
swap(str[l], str[r]);
r--;
}
l++;
}
printf("%s", str);
return 0;
}
(n/2)
(n/2)+1
n-1
n