題目:http://acm.hdu.edu.cn/showproblem.php?pid=2562
AC代碼(C++):
#include <iostream> #include <queue> #include <set> #include <string> #include <algorithm> #include <string.h> #include <math.h> #define INF 0x3f3f3f3f #define eps 1e-8 typedef unsigned long long ULL; using namespace std; char str[55]; int main() { int t; cin >> t; while (t--) { cin >> str; for (int i = 0; str[i] != '\0'; i++) { if (i % 2 == 0) { char tmp = str[i]; str[i] = str[i + 1]; str[i + 1] = tmp; } } cout << str << endl; } //system("pause"); }總結: 水題.