Răspuns:
#include <iostream>
using namespace std;
int main()
{
//1
int p,n,v[100],aparitii=0;
cout<<"p: ";
cin>>p;
cout<<"n: ";
cin>>n;
for(int i=1;i<=n;++i){
cin>>v[i];
if(v[i]==p){
aparitii++;
}
}
cout<<aparitii<<endl;
//2
int n1,v1[100],sum=0,nr=0;
cout<<"n: ";
cin>>n1;
for(int i=1;i<=n1;++i){
cin>>v1[i];
if(v1[i]>0 && v1[i]<100){
sum=sum+v1[i];
nr++;
}
}
float medie = (float)sum/nr;
cout<<medie;
return 0;
}
Explicație: