Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
112260 李朋秦 数组中元素交换 C++ Accepted 1 MS 272 KB 311 2025-03-09 09:38:49

Tests(10/10):


Code:

#include<bits/stdc++.h> using namespace std; int main() { int a[100],b,c=0; cin>>b; for(int i=0;i<b;i++){ cin>>a[i]; }for(int j=0;j<(b-1);j+=2){ c=a[j]; a[j]=a[j+1]; a[j+1]=c; } for(int d=0;d<b;d++){ cout<<a[d]; if(d!=b-1){ cout<<" "; } } cout<<endl; return 0; }