0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

はじめに

この記事は 共通テスト手順記述標準言語 (DNCL) Advent Calendar 2025 の10日目の記事です。

DNCLで文字列が回文かどうかを判定するプログラムを作りました。

回文判定

文字列を右端と左端から順に比較して一つでも異なる組があれば回文ではないとわかります。DNCLでは÷を使うと割り算の商が得られます。

bunsyo ← "たけやぶやけた"
mozisu ← 7
ans ← "回文である"

i を1から mozisu ÷ 2 まで1ずつ増やしながら、
|  もし bunsyo[i] != bunsyo[mozisu - i + 1]ならば
|  |  ans ← "回文ではない"
|  |  繰り返しを抜ける
|  を実行する
を繰り返す

ans を表示する

i = 3のときはi文字目と7 - 3 + 1 = 5のようにmozisu - i + 1文字目を比較することに注意が必要です。
また、文字の長さが奇数のときは真ん中の文字に言及することはありませんが、回文かどうかには影響しません。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?