Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
117383 翁思宸 数组中元素交换 C++ Accepted 1 MS 276 KB 519 2025-04-18 19:08:51

Tests(10/10):


Code:

#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ int i,a[10000],n,s; cin>>n; for(i=0;i<n;i++){ cin>>a[i]; } for(int j=0;j<n-1;j+=2){ s=a[j]; a[j]=a[j+1]; a[j+1]=s; } for(int k=0;k<n;k++){ cout<<a[k]<<" "; } return 0; }