Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iomanip>
- #include <iostream>
- #include <vector>
- #include <algorithm> // std::sort
- using namespace std;
- int main(){
- int num,taille,count(0);
- vector <int> in;
- vector <int> ::iterator it;
- do{//lire l'entrée jusqu'à 0
- cin>>num;
- in.push_back(num);
- }while (num!=0);
- taille = in.size()-1; //Taille moins le 0
- std::sort ( in.begin(), in.end()); //trier
- for (it=in.end();it>=in.begin();--it){
- if (num==*it ){count++;} //si c'est le même que le dernier count ++
- else if (num>0) {//différent affiche % et reset count
- cout <<"Num ="<<num<<" %"<< fixed << setprecision(1)<<(100* ( count*1.0 / taille )) << endl;
- count=1;}
- num=*it;//memoire dernier element
- in.pop_back();//Elimine le dernier element
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement