Problem p00017 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  int f = 0, i;
  for (;;) {
    char word[100] = {0};
    for (i = 0;; i++) {
      if (scanf("%c", &word[i]) == EOF) {
        f = 1;
        word[i] = 10;
        break;
      }
      if (word[i] == 10) {
        break;
      }
    }
    for (;;) {
      for (i = 0; i < (int)strlen(word); i++) {
        if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'i' &&
            word[i + 3] == 's' && word[i + 4] == ' ') {
          break;
        } else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'a' &&
                   word[i + 3] == 't' && word[i + 4] == ' ') {
          break;
        } else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'e' &&
                   word[i + 3] == ' ') {
          break;
        } else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'i' &&
                   word[i + 3] == 's' && word[i + 4] == '\n') {
          break;
        } else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'a' &&
                   word[i + 3] == 't' && word[i + 4] == '\n') {
          break;
        } else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'e' &&
                   word[i + 3] == '\n') {
          break;
        }
      }
      if (i != (int)strlen(word)) {
        cout << word;
        break;
      }
      for (i = 0; i < (int)strlen(word); i++) {
        if (word[i] == 122) {
          word[i] = 97;
        } else if (word[i] >= 97 && word[i] < 122) {
          word[i]++;
        }
      }
    }
    if (f == 1) {
      break;
    }
  }
  return 0;
}

Fixed submission:
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  int f = 0, i;
  for (;;) {
    char word[100] = {0};
    for (i = 0;; i++) {
      if (scanf("%c", &word[i]) == EOF) {
        f = 1;
        word[i] = 10;
        break;
      }
      if (word[i] == 10) {
        break;
      }
    }
    for (int l = 0; l < 26; l++) {
      for (i = 0; i < (int)strlen(word); i++) {
        if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'i' &&
            word[i + 3] == 's' && word[i + 4] == ' ') {
          break;
        } else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'a' &&
                   word[i + 3] == 't' && word[i + 4] == ' ') {
          break;
        } else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'e' &&
                   word[i + 3] == ' ') {
          break;
        } else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'i' &&
                   word[i + 3] == 's' && word[i + 4] == '\n') {
          break;
        } else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'a' &&
                   word[i + 3] == 't' && word[i + 4] == '\n') {
          break;
        } else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'e' &&
                   word[i + 3] == '\n') {
          break;
        }
      }
      if (i != (int)strlen(word)) {
        cout << word;
        break;
      }
      for (i = 0; i < (int)strlen(word); i++) {
        if (word[i] == 122) {
          word[i] = 97;
        } else if (word[i] >= 97 && word[i] < 122) {
          word[i]++;
        }
      }
    }
    if (f == 1) {
      break;
    }
  }
  return 0;
}