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. int k=0;
  24. for(int i=0; i < number_of_words; i++){
  25. for(j=0;)
  26. cipher_chunk[i][j]=cipher[k++];
  27. }
  28.  
  29. for (int i = 0; i < number_of_words; i++) {
  30. int shift = key[i];
  31.  
  32. for (size_t j = 0; j < strlen(cipher_chunk[i]); j++) {
  33. char c = cipher_chunk[i][j];
  34. if (islower(c)) {
  35. // TODO: decode lowercase letters
  36. } else {
  37. // TODO: decode uppercase letters
  38. }
  39. }
  40. decoded_chunk[i][strlen(cipher_chunk[i])] = '\0';
  41. }
  42.  
  43. for (int i = 0; i < number_of_words; i++) {
  44. printf("%s%c", decoded_chunk[i], " \n"[i == number_of_words - 1]);
  45. }
  46.  
  47. return 0;
  48. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty