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でシフト暗号を暗号化・復号する

0
Last updated at Posted at 2025-12-31

はじめに

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

DNCLでシフト暗号を使っていきます!

DNCLを書く

関数添え字(配列, 文字)を引数の配列文字に対応する値の添え字(0から始まる。)を返すものとします。kagiが何文字ずらすかを表します。

暗号化
mozi ← ["ア","イ","ウ","エ","オ","カ","キ","ク","ケ","コ","サ","シ","ス","セ","ソ","タ","チ","ツ","テ","ト","ナ","ニ","ヌ","ネ","ノ","ハ","ヒ","フ","ヘ","ホ","マ","ミ","ム","メ","モ","ヤ","ユ","ヨ","ラ","リ","ル","レ","ロ","ワ","ヲ","ン"]
bunsyo ← "クリスマス"
mozisu ← 5
kagi ← 3
ans ← ""

i を0から mozisu - 1 まで1ずつ増やしながら
|  v ← (添え字(mozi,bunsyo[i]) + kagi) % 要素数(mozi)
|  ans ← ans + mozi[v]
を繰り返す

ans を表示する
復号
mozi ← ["ア","イ","ウ","エ","オ","カ","キ","ク","ケ","コ","サ","シ","ス","セ","ソ","タ","チ","ツ","テ","ト","ナ","ニ","ヌ","ネ","ノ","ハ","ヒ","フ","ヘ","ホ","マ","ミ","ム","メ","モ","ヤ","ユ","ヨ","ラ","リ","ル","レ","ロ","ワ","ヲ","ン"]
bunsyo ← "クリスマス"
mozisu ← 5
kagi ← 3
ans ← ""

i を0から mozisu - 1 まで1ずつ増やしながら
|  v ← (添え字(mozi,bunsyo[i]) + 要素数(mozi) - kagi) % 要素数(mozi)
|  ans ← ans + mozi[v]
を繰り返す

ans を表示する
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?