Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <stdio.h>
- #include <cstring>
- #include <vector>
- #include <algorithm>
- #include <utility>
- #include <queue>
- #include <map>
- #include <stack>
- #include <cmath>
- #include <set>
- #include <ctype.h>
- #include <bitset>
- using namespace std;
- struct pessoa{
- char nome[30];
- int idade;
- };
- pessoa p[10];
- // ordena em ralação a menor altura
- // se empatar a altura, coloca em ordem alfabetica
- bool comp(pessoa a, pessoa b){
- if(a.idade < b.idade)
- return true;
- else if(b.idade < a.idade)
- return false;
- else if(strcmp(a.nome,b.nome) < 0)
- return true;
- else
- return false;
- }
- int main(){
- int n;
- cin>>n;
- getchar();
- for(int i=0; i<n; i++){
- cin>>p[i].idade>>p[i].nome;
- }
- sort(p,p+n,comp);
- for(int i=0; i<n; i++)
- cout<<p[i].idade<<" - "<<p[i].nome<<endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment