fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. #include <cstdint>
  5.  
  6. //大文字アルファベット縛り。
  7.  
  8. bool MakeHoge(std::string S) {
  9. std::string X = S;
  10. std::intmax_t c = 0;
  11. std::sort(X.begin(), X.end());
  12. for (auto& o : X) {
  13. if (o - 'A' == c) { c++; }
  14. else {
  15. std::cout <<S<<" => "<< static_cast<char>('A' + c) << std::endl;
  16. return true;
  17. }
  18. }
  19. return false;
  20. }
  21.  
  22. int main() {
  23. std::string S;
  24.  
  25. S = "BCDEFGHIJKLMNOPQRSTUVWXYZ";
  26. MakeHoge(S);
  27.  
  28. S = "YIZFOADLMWCRUTGSVQKJEHNBP";
  29. MakeHoge(S);
  30.  
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
BCDEFGHIJKLMNOPQRSTUVWXYZ => A
YIZFOADLMWCRUTGSVQKJEHNBP => X