Răspuns :
1)
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n,m,c;
cin >> n;
vector <int> a(n);
for (int i=0; i<a.size(); i++)
cin >> a[i];
m=*max_element(a.begin(),a.end());
cout << a.size()-count(a.begin(),a.end(),m);
return 0;
}
2)
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector <vector <int> > a(5);
for (int i=0; i<5; i++)
{
a[i].resize(5);
for (int j=0; j<5; j++)
cin >> a[i][j];
}
int s=0;
for (int i=4; i>=0; i--)
if (a[i][4-i]) s+=a[i][4-i];
cout << s;
return 0;
}
3)
#include <vector>
#include <iostream>
using namespace std;
vector <string> words(string s)
{
vector <string> a;
string x;
s+=' ';
for (int i=0; i<s.size(); i++)
{
if (s[i]!=' ') x+=s[i];
if (s[i]==' ' && x!="")
{
a.push_back(x);
x="";
}
}
return a;
}
main()
{
string s;
getline(cin,s);
vector <string> w;
w=words(s);
cout << w.size();
}
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n,m,c;
cin >> n;
vector <int> a(n);
for (int i=0; i<a.size(); i++)
cin >> a[i];
m=*max_element(a.begin(),a.end());
cout << a.size()-count(a.begin(),a.end(),m);
return 0;
}
2)
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector <vector <int> > a(5);
for (int i=0; i<5; i++)
{
a[i].resize(5);
for (int j=0; j<5; j++)
cin >> a[i][j];
}
int s=0;
for (int i=4; i>=0; i--)
if (a[i][4-i]) s+=a[i][4-i];
cout << s;
return 0;
}
3)
#include <vector>
#include <iostream>
using namespace std;
vector <string> words(string s)
{
vector <string> a;
string x;
s+=' ';
for (int i=0; i<s.size(); i++)
{
if (s[i]!=' ') x+=s[i];
if (s[i]==' ' && x!="")
{
a.push_back(x);
x="";
}
}
return a;
}
main()
{
string s;
getline(cin,s);
vector <string> w;
w=words(s);
cout << w.size();
}