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?

COBOLで遊ぼう(6):読みにくいCOBOLコードコンテスト

0
Last updated at Posted at 2026-04-03

はじめに

読みにくいCコードコンテスト、というものがあります。
サイトは以下です。
https://www.ioccc.org/
(The International Obfuscated C Code Contest)

COBOLでそんなコードを書いてみようと思いました。

とりあえずの1例

       REPLACE ==(9)==BY==A== ==(/9)==BY==B== ==(.)==BY==C== ==(-9)==BY
       ==D== ==(9.)==BY==E== ==(9=)==BY==F== ==(9*)==BY==G== ==Z==BY ==
       H== ==(-)==BY==I== ==(999)==BY==K== ==(.9)==BY==L== ==<==BY==M==
       ==(*)==BY==N== ==(+9)==BY==O== ==(*9)==BY==P== ==(9+)==BY==R==
       ==(9-)==BY==S== ==(=9)==BY==T== ==(=)==BY==U== ==(9/)==BY==V== ==
       (/)==BY==W== ==(+)==BY==Y==.
       (-)(-9)(9.)(*)(=9)(-)(9=)(-)(.)(9)(=9)(-)(+9)(*) 
       (-9)(-)(9/)(-)(9-)(-)(+9)(*). (*9)(9+)(+9)(9*)(9+)(9)<-(-)(-9). 
       (*9)9. (-9)(9)(=9)(9) (-9)(-)(9/)(-)(9-)(-)(+9)(*).
       (/)(+9)(9+)(999)(-)(*)(9*)-(9-)(=9)(+9)(9+)(9)(9*)(9.) 
       (9-)(9.)(.)(=9)(-)(+9)(*).
       1. 9 (9) (*9)(-)(.) 999. 9 (/9) (*9)(-)(.) 999. 9 (.) 
       (*9)(-)(.) 9.99.  9 (-9) (*9)(-)(.) 9 . 9 (9.) (*9)(-)(.)
        99. 9 (9=) (*9)(-)(.) 99 (+9)(.)(.)(=)(9+)(9-) 9.
       (*9)(9+)(+9)(.)(9.)(-9)(=)(9+)(9.) (-9)(-)(9/)(-)(9-)(-)(+9)(*)
       . <(+9)(9/)(9.) 99 (=9)(+9) (/9). (.)(+9)<(*9)(=)(=9)(9.)
       (9)=((9 + 9) + (9 + 9)) * 9 - 9 - (9/9). (.)(+9)<(*9)(=)(=9)(9.)
       (.)=(9) / ( (/9) + ( 9/9 ) ) . (.)(+9)<(*9)(=)(=9)(9.)
       (-9)=9/9. (.)(+9)<(*9)(=)(=9)(9.) (9.)=9*9.
       <(+9)(9/)(9.) (9.) (=9)(+9) (9=)((-9)). (.)(+9)<(*9)(=)(=9)(9.)
       (-9)=(-9) +(9/9). (.)(+9)<(*9)(=)(=9)(9.) (9.)=(/9) -
       (((/9) * 9)/(9 + 9 + 9)). <(+9)(9/)(9.)
       (9.) (=9)(+9) (9=)((-9)). (.)(+9)<(*9)(=)(=9)(9.)
       (-9)=(-9) + (9/9). (.)(+9)<(*9)(=)(=9)(9.)
       (9.)=(9*9) - 9 + (9/9) + (9/9). <(+9)(9/)(9.)
       (9.) (=9)(+9) (9=)((-9)). (.)(+9)<(*9)(=)(=9)(9.) (-9)=(-9)
       +(9/9).(.)(+9)<(*9)(=)(=9)(9.) (9.)=99 - 999/((9 + 9) + 9).
       <(+9)(9/)(9.) (9.) (=9)(+9) (9=)((-9)). (.)(+9)<(*9)(=)(=9)(9.)
       (9)=(9/9). (.)(+9)<(*9)(=)(=9)(9.) (/9)=((9 + 9) + (9 + 9))/9.
       (*9)(9.)(9+)(9=)(+9)(9+)< (9/)(9)(9+)(+)(-)(*)(9*) (-9) 
       (9=)(9+)(+9)< (9) (/9)(+) (9) (=)(*)(=9)(-)(.9) (-9)>(/9) 
       (-9)(-)(9-)(*9)(.9)(9)(+) (9=)(=)(*)(.)(=9)(-)(+9)(*) (.)Z(9)(9+)
       ((9=)((-9))) (*)(+9) (9)(-9)(9/)(9)(*)(.)(-)(*)(9*) 
       (9.)(*)(-9)-(*9)(9.)(9+)(9=)(+9)(9+)<. 
       (-9)(-)(9-)(*9)(.9)(9)(+) (.). 
       (9.)(*)(-9) (*9)(9+)(+9)(9*)(9+)(9)< (*9)9.

Rocket COBOL(Micro Focus COBOL)でコンパイル実行しました。

d:\temp>cbllink Obfuscated.cbl
Micro Focus COBOL - CBLLINK utility
Version 10.0.0.82 (C) Copyright 1984-2024 Micro Focus or one of its affiliates.

Micro Focus COBOL
Version 10.0 (C) Copyright 1984-2024 Micro Focus or one of its affiliates.
* チェック終了:エラーはありません - コード生成を開始します
* Generating Obfuscated
* Data:         128     Code:        1307     Literals:         128
Microsoft (R) Incremental Linker Version 14.38.33130.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Obfuscated.obj
cbllds000004A0.obj
   Creating library Obfuscated.lib and object Obfuscated.exp
Microsoft (R) Manifest Tool
Copyright (c) Microsoft Corporation.
All rights reserved.

d:\temp>Obfuscated.exe
PAI=3.14

分離符や正書法は新しい規格に沿って書いているので古いCOBOLコンパイラやgnu cobolでは通らないと思います

無粋を承知で解説すると、数字の9と四則演算を使い3.14を計算するCOBOLプログラムです。
また(REPLACE文で分解できないので)文字定数は使用していません。
"PAI="をどうやって書いているか追ってみて下さい😊

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?