Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
160010 鸡哥 数组中元素交换 C++ Compile Error 0 MS 0 KB 255 2026-09-12 13:42:41

Tests(0/0):


Code:

#include<bits/stdc++.h> using namespace std; int main(){ int a[101],x,n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } if(n%2==0){ for(int i=1,i<=n;i+=2){ x=a[i]; a[i]=a[i+1]; a[i+1]=x; cout<<a[i]; } } return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:10:16: error: expected ';' before '<=' token
   for(int i=1,i<=n;i+=2){
                ^
Main.cc:10:16: error: expected primary-expression before '<=' token