Răspuns:
La 4:
#include <iostream>
using namespace std;
int main()
{
int n,a[101],nr=1,Max;
cin>>n;
cin>>a[1];
Max=a[1];
for(int i=2;i<=n;i++)
{
cin>>a[i];
if(Max<a[i])
{
Max=a[i];
nr=0;
}
if(Max==a[i])
nr++;
}
if(n-nr>=n/2)
cout<<"DA";
else
cout<<"NU";
return 0;
}
La 5
#include <iostream>
using namespace std;
int main()
{
int k,n;
cin>>k>>n;
for(int i=n;i>=1;i--)
cout<<(i-1)/k+1<<" ";
return 0;
}
Explicație: