#include<iostream>
using namespace std;
#include<cstdio>
#include<string.h>
int a[101]={0};
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
int num;
cin>>num;
a[num]++;
}
int m;
cin>>m;
for(int i=0;i<m;i++){
int number;
cin>>number;
if(i!=m-1)
cout<<a[number]<<" ";
else
cout<<a[number]<<endl;
}
return 0;
}
这题当时报错千奇百怪的,后来我在vs2019上跑了一次才知道原来是main函数没有加()我真是笨死了啊,所以如果出现下面这种错误,一点要看看自己是不是犯了超级低级的错误啊。
[Warning] extended initializer lists only available with -std=c++11 or -std=gnu++11
[Error] expected primary- expression before "int'
[Error] expected ' before 'int'
[Error] expected ,' or ;' before 'int'
[Error] 'cin' does not name a type
[Error] expected unqualified-id before 'for'
[Error] T does not name a type
[Error] T' does not name a type
[Error] 'cin' does not name a type
[Error] expected unqualified-id before 'for'
[Error] T does not name a type