Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. /*
  2. * Matheus Oliveira
  3. * 22/03/2017
  4. * 1258.cpp
  5. */
  6.  
  7. #include <cstdio>
  8. #include <iostream>
  9. #include <string>
  10. #include <algorithm>
  11.  
  12. using namespace std;
  13.  
  14. struct infos {
  15.  
  16. string name;
  17. string color;
  18. char size;
  19.  
  20. } person[61];
  21.  
  22. bool compare (const infos &first, const infos &second) {
  23.  
  24. if(first.color == second.color) {
  25.  
  26. if(first.size == second.size) {
  27.  
  28. return first.name < second.name;
  29. }
  30.  
  31. return first.size > second.size;
  32. }
  33.  
  34. return first.color < second.color;
  35. }
  36.  
  37. int main () {
  38.  
  39. int n, i;
  40.  
  41. scanf("%d", &n);
  42.  
  43. getchar();
  44.  
  45. while(true) {
  46.  
  47. if(n == 0) break;
  48.  
  49. for(i=0; i < n; i++) {
  50.  
  51. getline(cin, person[i].name);
  52.  
  53. getline(cin, person[i].color, ' ');
  54.  
  55. scanf("%c", &person[i].size);
  56.  
  57. getchar();
  58. }
  59.  
  60. stable_sort(person, person+n, compare);
  61.  
  62. for(i=0; i < n; i++) {
  63.  
  64. cout << person[i].color << " " << person[i].size << " " << person[i].name << '\n';
  65. }
  66.  
  67. scanf("%d", &n);
  68.  
  69. getchar();
  70.  
  71. if(n != 0) printf("\n");
  72. }
  73.  
  74. return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement