Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
96535 吴天辰 数组中元素交换 C++ Compile Error 0 MS 0 KB 360 2024-11-09 11:12:54

Tests(0/0):


Code:

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


Run Info:

Main.cc: In function 'int main()':
Main.cc:8:7: error: 'a' was not declared in this scope
  cin>>a[i];
       ^
Main.cc:11:5: error: 'a' was not declared in this scope
   t=a[i];
     ^
Main.cc:19:5: error: 'a' was not declared in this scope
   t=a[i];
     ^
Main.cc:25:9: error: 'a' was not declared in this scope
   cout<