0

finding the mode of strings

hello im asked to find the mode of set of strings and this is my code #include<iostream> #include<vector> #include<string> using namespace std; int main(){ vector<string>com; vector<int>mode; int count; string num; count=0; for(int i=1;i<10;i++){ cin>>num; com.push_back(num); } for(int k=0;k<com.size();k++){ for(int j=0; j<com.size();j++){ if(com[j]==com[k]){ count+=1; continue;} else; continue; mode.push_back(count); count=0; } sort(mode.begin(),mode.end()); cout<<mode[mode.size()-1]; } my problem is : how can i get the code to type the mode at the end , the thing is after sorting i dont know the relation between the position of the mode in the mode vector before and after sorting_contrary to the case before sorting where the string position is as the same as its count position in mode vector.

25th Oct 2022, 11:21 PM
Abdullah Othman
Abdullah Othman - avatar
1 Réponse
+ 1
The problem is solved?
29th Oct 2022, 10:36 AM
Ipang