Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
108553 | 6张轶涵 | 数组中元素交换 | C++ | Wrong Answer | 1 MS | 276 KB | 275 | 2025-01-20 19:30:34 |
#include <bits/stdc++.h> using namespace std; int a[1005]; int main() { int n; cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; } int d=n/2; for(int i=1;i<=d;i+=2) { swap(a[i],a[i+1]); } for(int i=1;i<=n;i++) { cout<<a[i]<<" "; } return 0; }
------Input------
5 81 43 69 80 80
------Answer-----
43 81 80 69 80
------Your output-----
43 81 69 80 80