Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<algorithm>
- #include<stdio.h>
- #include<stdlib.h>
- #include<vector>
- #include<string>
- #include<list>
- using namespace std;
- class Elev{
- public:
- string nume;
- float n1;
- Elev(string nume,float n1){
- this->nume=nume;
- this->n1=n1;
- }
- bool operator<(Elev &e){
- if(n1<e.n1)
- return false;
- else if(n1>e.n1)
- return true;
- else{
- if(nume<e.nume)
- return true;
- else
- return false;
- }
- }
- };
- int main(){
- float n1;
- char nume[64];
- vector<Elev> elevi;
- while(EOF!=scanf("%[^,],%f\n",nume,&n1)){
- bool exista=false;
- for(int i=0;i<elevi.size();i++){
- if(elevi[i].nume==nume)exista=true;
- }
- if(!exista)
- elevi.emplace_back(nume,n1);
- }
- sort(elevi.begin(),elevi.end());
- for(int i=0;i<elevi.size();i++){
- printf("%s,%.2f\n",elevi[i].nume.c_str(),elevi[i].n1);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement