Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- int main(){
- int repeatedNums[10]{0};
- int vSize=0;
- cin>>vSize;
- vector <int> myVector;
- for(int a=0; a<vSize; a++){
- int input=0;
- cin>>input;
- repeatedNums[input]+=1;
- myVector.push_back(input);
- }
- int maximum=-1;
- vector<int>concatenated;
- int counter=1;
- bool validate=false;
- for(int a=0; a<10 ;a++ ){
- if(repeatedNums[a]>maximum){
- maximum=repeatedNums[a];
- counter=a;
- validate=false;
- }
- if(repeatedNums[a]==maximum && counter!=a){
- if(validate==false){
- concatenated.push_back(counter);
- }
- concatenated.push_back(a);
- validate=true;
- }
- }
- if(validate==false){
- cout<<counter;
- } else {
- for(int& a : concatenated){
- cout<< a << " ";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment