Guest User

Untitled

a guest
Feb 24th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. using namespace std;
  4.  
  5. void func(char code, char x, char y, int i, int ap[]) {
  6. if (code == x || code == y)
  7. ap[i]++;
  8. else
  9. func(code, ++x, ++y, ++i, ap);
  10. }
  11.  
  12. int func2(int ap[]) {
  13. int i, max = 0, count = 0;
  14. //max값 뽑아내기
  15. for (i = 0; i < 26; i++) {
  16. if (max < ap[i])
  17. max = ap[i];
  18. }
  19. //가장 높은 알파벳 번호 찾기
  20. for (i = 0; i < 26; i++) {
  21. if (max == ap[i])
  22. break;
  23. }
  24. //중복체크
  25. for (int j = 0; j < 26; j++) {
  26. if (max == ap[j])
  27. count++;
  28. }
  29.  
  30. if (count >= 2)
  31. return -1;
  32. else
  33. return i;
  34. }
  35.  
  36.  
  37. int main() {
  38. string input;
  39. char code;
  40. int ap[26] = { 0 };
  41. char result;
  42.  
  43. cin >> input;
  44.  
  45. for (int i = 0; i < input.length(); i++) {
  46. code = input.at(i);
  47. func(code, 'a', 'A', 0, ap);
  48. }
  49.  
  50. if (func2(ap) == -1)
  51. result = '?';
  52. else
  53. result = func2(ap) + 65;
  54.  
  55. printf("%c", result);
  56. }
Add Comment
Please, Sign In to add comment