输出的字符串由大写字母组成,并且所有相邻的字符最多只有一对ASCII码的奇偶性不同。( )
#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;
}
正确
错误