Advertisement
MonsterScripter

CodinGame_2023_08_23__23_17_00__upper.c

Aug 23rd, 2023 (edited)
1,186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdbool.h>
  5.  
  6. /**
  7.  * You need to create a program that retrieves all the uppercase letters from a specific text input.
  8.  * However, if there are no uppercase letters found, the program should print the constant value None.
  9.  * Players must reverse engineer the code to find the original uppercase letters or determine that there are none.
  10.  *
  11.  * Entrée:
  12.  * string
  13.  *
  14.  * Sortie:
  15.  * string
  16.  *
  17.  * Contraintes:
  18.  *
  19.  * Exemple:
  20.  * Entrée:
  21.  * abcdABCD
  22.  * Sortie:
  23.  * ABCD
  24.  */
  25.  
  26. int main()
  27. {
  28.     char s[257];
  29.     scanf("%[^\n]", s);
  30.     int x=0;
  31.     bool f=0;
  32.     char tab[strlen(s)];
  33.     int cpt=0;
  34.     for (int i=0; i<strlen(s); i++) {
  35.         if (s[i] >= 'A' && s[i] <= 'Z' ) {
  36.             tab[cpt++] = s[i];
  37.             f=true;
  38.         }
  39.     }
  40.     if (!f) {
  41.         printf("%s\n", "None");
  42.     } else {
  43.         printf("%s\n", tab);
  44.     }
  45.  
  46.     return 0;
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement