| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 151974 | 何兴驰 | 18查找该数出现的位置 | C++ | Accepted | 2 MS | 276 KB | 437 | 2026-04-19 12:43:44 |
#include<bits/stdc++.h> using namespace std; int main(){ int n,m,q=-1,o=-1; cin>>n; int a[n+1]; for(int z=1;z<=n;z++){ cin>>a[z]; } cin>>m; for(int i=1;i<=n;i++){ if(m==a[i]){ q=i; break; } } for(int i=n;i>=1;i--){ if(m==a[i]){ o=i; break; } } if(o==-1){ cout<<-1; }else{ cout<<q<<" "<<o; } return 0; }