fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. struct sigma {
  6. int id, atk, def;
  7. char name[35];
  8. };
  9.  
  10. int main () {
  11. int n; scanf("%d", &n);
  12. struct sigma students[1005];
  13. for(int i = 0; i < n; i++)
  14. scanf("%d %s %d %d", &students[i].id, students[i].name, &students[i].atk, &students[i].def);
  15. int q; scanf("%d", &q);
  16. while(q--) {
  17. int x; scanf("%d", &x);
  18. if(x == 1) {
  19. int idx; scanf("%d", &idx);
  20. int found = -1;
  21. for(int i = 0; i < n; i++) {
  22. if(students[i].id == idx) {
  23. found = i; break;
  24. }
  25. }
  26. if(found == -1) printf("Player Not Found\n");
  27. else printf("%s\n", students[found].name);
  28. } else if (x == 2) {
  29. char nama[35]; scanf("%s", &nama);
  30. int found = -1;
  31. for(int i = 0; i < n; i++) {
  32. if(strcmp(students[i].name, nama) == 0) {
  33. found = i; break;
  34. }
  35. }
  36. if(found == -1) printf("Player Not Found\n");
  37. else printf("%d\n", students[found].id);
  38. } else if (x == 3) {
  39. int hival = -1, hiidx = -1;
  40. for(int i = 0; i < n; i++) {
  41. if(hival < students[i].atk) {
  42. hival = students[i].atk; hiidx = i;
  43. }
  44. }
  45. printf("%s\n", students[hiidx].name);
  46. } else {
  47. int hival = -1, hiidx = -1;
  48. for(int i = 0; i < n; i++) {
  49. if(hival < students[i].def) {
  50. hival = students[i].def; hiidx = i;
  51. }
  52. }
  53. printf("%s\n", students[hiidx].name);
  54. }
  55. }
  56.  
  57. return 0;
  58. }
Success #stdin #stdout 0s 544KB
stdin
5
8 Szoboszlai 83 66
7 Wirtz 86 50
42 Nyoni 84 72
29 Barcola 85 30
5 Jacquet 35 83
6
1 42
1 1
2 Salah
2 Wirtz
3
4
stdout
Nyoni
Player Not Found
Player Not Found
7
Wirtz
Jacquet