Advertisement
unknown_0711

Untitled

Aug 12th, 2022
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. public class Main {
  6. public static void main (String[] args) throws java.lang.Exception {
  7. Scanner sc = new Scanner(System.in);
  8. //int m=sc.nextInt();
  9.  
  10. String s = sc.nextLine();
  11. int n = s.length();
  12. int a = 0;
  13. int b = 0;
  14. int c = 0;
  15.  
  16. for (int i = 0; i < n; i = i + 3) { //Adrian
  17. if (s.charAt(i) == 'A') {
  18. a++;
  19. }
  20.  
  21. }
  22. for (int i = 1; i < n; i = i + 3) {
  23. if (s.charAt(i) == 'B') {
  24. a++;
  25. }
  26.  
  27. }
  28. for (int i = 2; i < n; i = i + 3) {
  29. if (s.charAt(i) == 'C') {
  30. a++;
  31. }
  32.  
  33. }
  34.  
  35.  
  36.  
  37.  
  38.  
  39. for (int i = 0; i < n; i = i + 3) { //Bruno
  40. if (s.charAt(i) == 'B') {
  41. b++;
  42. }
  43.  
  44. }
  45. for (int i = 1; i < n; i = i + 3) {
  46. if (s.charAt(i) == 'C') {
  47. b++;
  48. }
  49.  
  50. }
  51. for (int i = 2; i < n; i = i + 3) {
  52. if (s.charAt(i) == 'A') {
  53. b++;
  54. }
  55.  
  56. }
  57.  
  58.  
  59. for (int i = 0; i < n; i = i + 3) { //Goran
  60. if (s.charAt(i) == 'C') {
  61. c++;
  62. }
  63.  
  64. }
  65. for (int i = 1; i < n; i = i + 3) {
  66. if (s.charAt(i) == 'A') {
  67. c++;
  68. }
  69.  
  70. }
  71. for (int i = 2; i < n; i = i + 3) {
  72. if (s.charAt(i) == 'B') {
  73. c++;
  74. }
  75.  
  76. }
  77. System.out.print(a + "\n");
  78. System.out.print(b + "\n");
  79. System.out.print(c + "\n");
  80. int max = 100;
  81. if (max == a) {
  82. System.out.print(a + "\n");
  83. System.out.print("Adrain");
  84.  
  85.  
  86. }
  87.  
  88. if (max == b) {
  89. System.out.print(b + "\n");
  90. System.out.print("Bruno");
  91.  
  92.  
  93. }
  94. if (max == c) {
  95. System.out.print(c + "\n");
  96. System.out.print("Goran");
  97.  
  98.  
  99. }
  100.  
  101. }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement