fork(1) download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main() {
  5. char frase[200];
  6. printf("String: ");
  7. scanf("%200s", frase);
  8. for (int i = 0; i < strlen(frase); i++) {
  9. if (frase[i] >= 'A' && frase[i] <= 'Z') { //só altera se estiver na faixa correta
  10. if (frase[i] > 'W') { //trata os casos que precisam girar a tabela
  11. frase[i] += -23;
  12. } else {
  13. frase[i] += 3;
  14. }
  15. }
  16. }
  17. printf("String: %s", frase);
  18. }
  19.  
  20. //https://pt.stackoverflow.com/q/213908/101
Success #stdin #stdout 0s 4156KB
stdin
ABCHXYZ

stdout
String: String: DEFKABC