Nerde Nolzda

ZeroJudge: a022 迴文

直接 loop 檢查頭尾。
Loop to check front-to-back and back-to-front.

ZeroJudge Link (Zh)

#include <stdio.h>

main() {
  char str[1000];
  while (scanf("%s", str) != EOF) {
    int i, len = strlen(str), ans = 1;
    for (i = 0; i < len / 2; i++) {
      if (str[i] != str[len - i - 1]) {
        ans = 0;
        break;
      }
    }
    printf("%s\n", ans ? "yes" : "no");
  }
  return 0;
}

Related Posts

0 comments

Post a comment

Send an email to comment@nerde.pw.