65,210
社区成员
发帖
与我相关
我的任务
分享
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<int> int_vec;
vector<int> int_vec_backup;
void my_count() {
for ( vector<int>::const_iterator iter = int_vec.begin();iter != int_vec.end(); ++iter ) {
if ( int_vec_backup.end() == find( int_vec_backup.begin(), int_vec_backup.end(), *iter ) ) {
cout << *iter << "appears" << count( int_vec.begin(), int_vec.end(), *iter ) << "time(s)" << endl;
int_vec_backup.push_back( *iter );
}
else {
// nothing to do.
}
}
}
int main()
{
int n = 0;
cout << "please input next number :" << endl;
while ( cin >> n ) {
cout << "please input next number :" << endl;
int_vec.push_back( n );
}
my_count();
system( "pause" );
return 0;
}