Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
124160 陈华仁星 数组中元素交换 C++ Accepted 1 MS 200 KB 329 2025-07-11 10:06:57

Tests(10/10):


Code:

#include <cstdio> #include <algorithm> using namespace std; const int MAX=1e6; int a[MAX]; int main() { int n; scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&a[i]); } for(int i=1;i<n;i+=2) { swap(a[i],a[i+1]); printf("%d %d ",a[i],a[i+1]); } if(n%2!=0) printf("%d",a[n]); return 0; }