#include<iostream>
#include<vector>
#include<algorithm>//for sorting
using namespace std;
int main()
{
cout<<"enetr the string"<<endl;
string words;
vector<string> stringHolder;
while(cin>>words){
stringHolder.push_back(words);
}
sort(stringHolder.begin(),stringHolder.end());
int vsize=stringHolder.size();
if(vsize==0)
{
cout<<"no words"<<endl;
}
int wc=1;
words=stringHolder[0];
for(int i=1;i<vsize;i++)
{
if(words!=stringHolder[i]){
cout<<words<<" appare " <<wc<<" times"<<endl;
wc=0;
words=stringHolder[i];
}
wc++;
}
}
what is output of this program
Answers
Answered by
0
Answer:
Ascending order- 4,56,078;5,60,784;6,07,845;7,08,456;8,54,760.
Descending order-y
Similar questions