fahimkamal63

B. Sort and Print

Sep 27th, 2019
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. B. Sort and Print
  2.  
  3. Score: 1
  4.  
  5. CPU: 1s
  6. Memory: 1511MB
  7.  
  8.  
  9. Given a list of students with roll, name and marks of the students. Sort the students according to the marks first. If two student have scored the same mark, then sort them according to their roll number. Print the sorted list of the students following a formatted representation of roll, name and marks.
  10.  
  11.  
  12. Input
  13. The input will start with a number N (1 <= N <= 100) representing the total number of students. There will be three inputs for each students to get there roll, name and marks. Roll will be less than 100, name will have at most 10 characters and marks will be less than or equal to 100.
  14.  
  15.  
  16. Output
  17. The output will display the sorted list of the students according to the obtained marks first and then their roll number in the following format.
  18.  
  19.  
  20. Samples
  21. Input  
  22. 3
  23. 20
  24. abul
  25. 0
  26. 7
  27. babul
  28. 0
  29. 1
  30. kabul
  31. 100
  32.  
  33. Output
  34.  
  35. Roll | Name       | Marks
  36. -------------------------
  37.    1 | kabul      | 100
  38.    7 | babul      | 0
  39.   20 | abul       | 0
  40.  
  41. Input  
  42. 4
  43. 1
  44. aa
  45. 90
  46. 5
  47. bb
  48. 80
  49. 12
  50. cc
  51. 90
  52. 3
  53. dd
  54. 80
  55.  
  56. Output
  57.  
  58. Roll | Name       | Marks
  59. -------------------------
  60.    1 | aa         | 90
  61.   12 | cc         | 90
  62.    3 | dd         | 80
  63.    5 | bb         | 80
Advertisement
Add Comment
Please, Sign In to add comment