-3
문제 문 링크에서 SIGSEGV 오류 : - http://www.hackerearth.com/problem/algorithm/range-query/런타임 - 아래 코드
내 솔루션 : -
#include <iostream>
using namespace std;
int main()
{
long long n=0,q=0,x=0,y=0,val=0; //initialize variables
int a[1000];
int counter=0;
cin >>n ;
for (int i=0;i<n;i++)
{
cin >>a[i]; //populate the array
}
cin >>q;
for (int k=0;k<q;k++)
{
cin >>x >>y >>val;
for (int j=x;j<=y;j++)
{
if (a[j]==val)
counter++;
}
cout <<counter << "\n";
x=0;
y=0;
val=0;
counter=0;
a[10]=0;
}
return 0;
}
오류 : - 위의 코드를 실행하는 동안 SIGSEGV 오류가 발생했습니다.
덕분에, 잘 일이다! – user2295715