Advertisement
Guest User

Untitled

a guest
May 28th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. #include "stdio.h"
  2.  
  3.  
  4. int main() {
  5. int count, rate, school;
  6. char *last, *first;
  7.  
  8. int max = -1;
  9. int max_count = 0;
  10. char* max_last;
  11. char* max_first;
  12. char* max_last_second;
  13. char* max_first_second;
  14.  
  15. int max2 = -1;
  16. int max2_count = 0;
  17. char* max2_last;
  18. char* max2_first;
  19.  
  20.  
  21. scanf("%d",&count);
  22. for(int i=0;i < count;i++){
  23. scanf("%s", last);
  24. scanf("%s", first);
  25. scanf("%d", &school);
  26. scanf("%d", &rate);
  27.  
  28. if (school == 50) {
  29. if(rate > max){
  30. max2 = max;
  31. max2_count = 1;
  32.  
  33. max = rate;
  34. max_count = 0;
  35.  
  36. max_last = last;
  37. max_first = first;
  38. }
  39. if(rate == max) {
  40. max_count++;
  41.  
  42. max_last_second = last;
  43. max_first_second = first;
  44. }
  45.  
  46.  
  47. if(max2 < rate && rate < max){
  48. max2 = rate;
  49. max2_count = 0;
  50.  
  51. max2_last = last;
  52. max2_first = first;
  53. }
  54. if(rate == max2) {
  55. max2_count++;
  56. }
  57. }
  58.  
  59. }
  60.  
  61. if(max_count == 2){
  62. printf("%s", max_last);
  63. printf("%s", max_last_second);
  64. }
  65.  
  66. if(max_count > 2){
  67. printf("%d", max_count);
  68.  
  69. }
  70.  
  71. if(max_count == 1 && max2_count > 1){
  72. printf("%s", max2_last);
  73. }
  74.  
  75. printf("max: %d\n", max );
  76. printf("max_count: %d\n", max_count );
  77. printf("max2: %d\n", max2 );
  78. printf("max2_count: %d\n", max2_count );
  79. return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement