Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
151996 卢语宸 18查找该数出现的位置 C++ Runtime Error 1 MS 280 KB 494 2026-04-19 14:17:01

Tests(1/10):


Code:

#include<bits/stdc++.h> using namespace std; int a[1000],b=0,c=0,w=0,e=0; int main() { int y=0; cin>>b; for(int i=1; i<=b; i++) { cin>>a[i]; } cin>>c; for(int i=1; i<=b; i++) { if(a[i]!=c) { y++; } if(y==b) { cout<<-1; return 0; } } for(int i=1; i<=b; i++) { w++; if(a[i]==c) { break; } } e=b; for(int i=b; i>=1; i--) { if(a[i]!=c) { e--; } if(a[i]==c) { break; } } cout<<w<<" "<<e; return 0; }


Run Info:

Runtime Error:Segmentation fault