MonsterScripter

CodinGame_2023_08_26__19_59_40__occ_diff.cpp

Aug 27th, 2023
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <cstdlib>
  6.  
  7. using namespace std;
  8.  
  9. /**
  10.  * Objectif
  11.  * Retourner le code ASCII le plus grand parmi les caractères contenus dans le mot !
  12.  *
  13.  * Entrée
  14.  * Ligne 1 : le mot
  15.  *
  16.  * Sortie
  17.  * Ligne 1 : le code ASCII le plus grand
  18.  *
  19.  * Contraintes
  20.  * 1 <= longueur(mot) <= 100
  21.  * Le mot ne contient pas d'espace.
  22.  *
  23.  * Exemple
  24.  * Entrée
  25.  * a
  26.  * Sortie
  27.  * 97
  28.  */
  29.  
  30. int main()
  31. {
  32.     string word;
  33.     getline(cin, word);
  34.     sort(word.begin(), word.end()); // Trie le mot par ordre croissant des caractères ASCII
  35.     cout << (int) word[word.length() - 1] << endl; // Affiche le code ASCII du dernier caractère (le plus grand)
  36.     return EXIT_SUCCESS;
  37. }
  38.  
Add Comment
Please, Sign In to add comment