Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
146357 刘杨国卿 数组中元素交换 C++ Compile Error 0 MS 0 KB 272 2026-01-28 11:48:43

Tests(0/0):


Code:

#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int a[101]; for(int i=1;i<=n;i++){ cin>>a[i]; } for(int i=2;i<=n;i+=2){ int 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:16:13: error: no match for 'operator<' (operand types are 'std::basic_ostream' and 'const char [2]')
   cout< constexpr bool std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
     ^
/usr/include/c++/5/bits/stl_pair.h:220:5: note:   template argument deduction/substitution failed:
Main.cc:16:14: note:   'std::basic_ostream' is not derived from 'const std::pair<_T1, _T2>'
   cout<