Ответы
Ответ дал:
0
Предполагается, что первым числом подается количество N чисел на ввод, а затем эти же N чисел.
Тогда код выглядит вот так.
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;
int main() {
int n;
vector<int> x;
cin>>n;
x.resize(n);
while(n--) cin>>x[n];
std::unique(x.begin(),x.end());
cout<<x.size();
return 0;
}
Тогда код выглядит вот так.
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;
int main() {
int n;
vector<int> x;
cin>>n;
x.resize(n);
while(n--) cin>>x[n];
std::unique(x.begin(),x.end());
cout<<x.size();
return 0;
}
Вас заинтересует
2 года назад
2 года назад
7 лет назад
7 лет назад
10 лет назад
10 лет назад
10 лет назад