fork download
  1. #include <ctype.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. int main() {
  6. const int max_words = 20000;
  7. char cipher[(max_words) * 11];
  8. char cipher_chunk[max_words][10 + 1];
  9. char decoded_chunk[max_words][10 + 1];
  10. int key[max_words];
  11.  
  12. int number_of_words;
  13. scanf("%d", &number_of_words);
  14. scanf("%s", cipher);
  15. for (int i = 0; i < number_of_words; i++) {
  16. scanf("%d", &key[i]);
  17. }
  18.  
  19.  
  20. const char delimiter_set[] = ",.-";
  21. // TODO: split the cipher into chunks
  22. // HINT: strtok() & strcpy()
  23. for(int i=0;cipher[i]!='\0';i++){
  24. cipher_chunk[max_words][10 + 1];
  25. }
  26.  
  27. for (int i = 0; i < number_of_words; i++) {
  28. int shift = key[i];
  29.  
  30. for (size_t j = 0; j < strlen(cipher_chunk[i]); j++) {
  31. char c = cipher_chunk[i][j];
  32. if (islower(c)) {
  33. // TODO: decode lowercase letters
  34. } else {
  35. // TODO: decode uppercase letters
  36. }
  37. }
  38. decoded_chunk[i][strlen(cipher_chunk[i])] = '\0';
  39. }
  40.  
  41. for (int i = 0; i < number_of_words; i++) {
  42. printf("%s%c", decoded_chunk[i], " \n"[i == number_of_words - 1]);
  43. }
  44.  
  45. return 0;
  46. }
  47.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty