十六章第四题

#include<iostream>
#include<list>
#include<algorithm>
#include<vector>
using namespace std;
int reduce(long ar[], int n);
int main()
{
    
    
 const int num = 10;
 long arr[num] = {
    
     1,5,5,8,3,3,3,2,9,9 };
 int n = reduce(arr, num);
 cout << n;
 return 0;
}
int reduce(long ar[], int n)
{
    
    
 list<long> two;
 two.insert(two.begin(), ar, ar + n);
 two.unique();
 return (two.size());
}

猜你喜欢

转载自blog.csdn.net/wode_0828/article/details/108837157