Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
80821 刘慕莀 18第一次出现与最后一次出现的位置 C++ Compile Error 0 MS 0 KB 340 2024-07-11 16:30:44

Tests(0/0):


Code:

#include<bits/stdc++.h> using namespace std; int a[1000001]; int main(){ int n,m; int f=0,e=0; cin>>n; for(int i=1; i<=n;i++){ cin>>a[i]; } cin>>m; for(int i=1; i<=n;i++){ if(a[i]==k){ if(f==0){ f=i; } e=i; } } if(f==0){ cout<<-1; }else{ cout<<f<<' '<<e; } return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:13:15: error: 'k' was not declared in this scope
      if(a[i]==k){
               ^