WeixiangYan/CodeTransOcean huggingface dataset:
Task: Cantor set







Python: WIDTH = 81
HEIGHT = 5

lines=[]
def cantor(start, len, index):
    seg = len / 3
    if seg == 0:
        return None
    for it in xrange(HEIGHT-index):
        i = index + it
        for jt in xrange(seg):
            j = start + seg + jt
            pos = i * WIDTH + j
            lines[pos] = ' '
    cantor(start,           seg, index + 1)
    cantor(start + seg * 2, seg, index + 1)
    return None

lines = ['*'] * (WIDTH*HEIGHT)
cantor(0, WIDTH, 1)

for i in xrange(HEIGHT):
    beg = WIDTH * i
    print ''.join(lines[beg : beg+WIDTH])





Ada: with Ada.Text_IO;

procedure Cantor_Set is

   subtype Level_Range is Integer range 1 .. 5;
   Image : array (Level_Range) of String (1 .. 81) := (others => (others => ' '));

   procedure Cantor (Level : Natural; Length : Natural; Start : Natural) is
   begin
      if Level in Level_Range then
         Image (Level) (Start .. Start + Length - 1) := (others => '*');
         Cantor (Level + 1, Length / 3, Start);
         Cantor (Level + 1, Length / 3, Start + 2 * Length / 3);
      end if;
   end Cantor;
begin
   Cantor (Level  => Level_Range'First,
           Length => 81,
           Start  => 1);

   for L in Level_Range loop
      Ada.Text_IO.Put_Line (Image (L));
   end loop;
end Cantor_Set;
Task: Cantor set








VB: Module Module1

    Const WIDTH = 81
    Const HEIGHT = 5
    Dim lines(HEIGHT, WIDTH) As Char

    Sub Init()
        For i = 0 To HEIGHT - 1
            For j = 0 To WIDTH - 1
                lines(i, j) = "*"
            Next
        Next
    End Sub

    Sub Cantor(start As Integer, len As Integer, index As Integer)
        Dim seg As Integer = len / 3
        If seg = 0 Then
            Return
        End If
        For i = index To HEIGHT - 1
            For j = start + seg To start + seg * 2 - 1
                lines(i, j) = " "
            Next
        Next
        Cantor(start, seg, index + 1)
        Cantor(start + seg * 2, seg, index + 1)
    End Sub

    Sub Main()
        Init()
        Cantor(0, WIDTH, 1)
        For i = 0 To HEIGHT - 1
            For j = 0 To WIDTH - 1
                Console.Write(lines(i, j))
            Next
            Console.WriteLine()
        Next
    End Sub

End Module




Ada: with Ada.Text_IO;

procedure Cantor_Set is

   subtype Level_Range is Integer range 1 .. 5;
   Image : array (Level_Range) of String (1 .. 81) := (others => (others => ' '));

   procedure Cantor (Level : Natural; Length : Natural; Start : Natural) is
   begin
      if Level in Level_Range then
         Image (Level) (Start .. Start + Length - 1) := (others => '*');
         Cantor (Level + 1, Length / 3, Start);
         Cantor (Level + 1, Length / 3, Start + 2 * Length / 3);
      end if;
   end Cantor;
begin
   Cantor (Level  => Level_Range'First,
           Length => 81,
           Start  => 1);

   for L in Level_Range loop
      Ada.Text_IO.Put_Line (Image (L));
   end loop;
end Cantor_Set;
Task: Cantor set

C: #include <stdio.h>

#define WIDTH 81
#define HEIGHT 5

char lines[HEIGHT][WIDTH];

void init() {
    int i, j;
    for (i = 0; i < HEIGHT; ++i) {
        for (j = 0; j < WIDTH; ++j) lines[i][j] = '*';
    }
}

void cantor(int start, int len, int index) {
    int i, j, seg = len / 3;
    if (seg == 0) return;
    for (i = index; i < HEIGHT; ++i) {
        for (j = start + seg; j < start + seg * 2; ++j) lines[i][j] = ' ';
    }
    cantor(start, seg, index + 1);
    cantor(start + seg * 2, seg, index + 1);
}

void print() {
    int i, j;
    for (i = 0; i < HEIGHT; ++i) {
        for (j = 0; j < WIDTH; ++j) printf("%c", lines[i][j]);
        printf("\n");
    }
}

int main() {
    init();
    cantor(0, WIDTH, 1);
    print();
    return 0;
}
Task: Cantor set



C#: using System;

namespace CantorSet {
    class Program {
        const int WIDTH = 81;
        const int HEIGHT = 5;
        private static char[,] lines = new char[HEIGHT, WIDTH];

        static Program() {
            for (int i = 0; i < HEIGHT; i++) {
                for (int j = 0; j < WIDTH; j++) {
                    lines[i, j] = '*';
                }
            }
        }

        private static void Cantor(int start, int len, int index) {
            int seg = len / 3;
            if (seg == 0) return;
            for (int i = index; i < HEIGHT; i++) {
                for (int j = start + seg; j < start + seg * 2; j++) {
                    lines[i, j] = ' ';
                }
            }
            Cantor(start, seg, index + 1);
            Cantor(start + seg * 2, seg, index + 1);
        }

        static void Main(string[] args) {
            Cantor(0, WIDTH, 1);
            for (int i = 0; i < HEIGHT; i++) {
                for (int j = 0; j < WIDTH; j++) {
                    Console.Write(lines[i,j]);
                }
                Console.WriteLine();
            }
        }
    }
}
Task: Cantor set


C++: #include <iostream>

const int WIDTH = 81;
const int HEIGHT = 5;

char lines[WIDTH*HEIGHT];

void cantor(int start, int len, int index) {
	int seg = len / 3;
	if (seg == 0) return;
	for (int i = index; i < HEIGHT; i++) {
		for (int j = start + seg; j < start + seg * 2; j++) {
			int pos = i * WIDTH + j;
			lines[pos] = ' ';
		}
	}
	cantor(start,           seg, index + 1);
	cantor(start + 2 * seg, seg, index + 1);
}

int main() {
	
	for (int i = 0; i < WIDTH*HEIGHT; i++) {
		lines[i] = '*';
	}

	
	cantor(0, WIDTH, 1);

	
	for (int i = 0; i < HEIGHT*WIDTH; i += WIDTH) {
		printf("%.*s\n", WIDTH, lines + i);
	}

	return 0;
}
Task: Cantor set





Java: public class App {
    private static final int WIDTH = 81;
    private static final int HEIGHT = 5;

    private static char[][] lines;
    static {
        lines = new char[HEIGHT][WIDTH];
        for (int i = 0; i < HEIGHT; i++) {
            for (int j = 0; j < WIDTH; j++) {
                lines[i][j] = '*';
            }
        }
    }

    private static void cantor(int start, int len, int index) {
        int seg = len / 3;
        if (seg == 0) return;
        for (int i = index; i < HEIGHT; i++) {
            for (int j = start + seg; j < start + seg * 2; j++) {
                lines[i][j] = ' ';
            }
        }
        cantor(start, seg, index + 1);
        cantor(start + seg * 2, seg, index + 1);
    }

    public static void main(String[] args) {
        cantor(0, WIDTH, 1);
        for (int i = 0; i < HEIGHT; i++) {
            for (int j = 0; j < WIDTH; j++) {
                System.out.print(lines[i][j]);
            }
            System.out.println();
        }
    }
}
Task: Cantor set







Python: WIDTH = 81
HEIGHT = 5

lines=[]
def cantor(start, len, index):
    seg = len / 3
    if seg == 0:
        return None
    for it in xrange(HEIGHT-index):
        i = index + it
        for jt in xrange(seg):
            j = start + seg + jt
            pos = i * WIDTH + j
            lines[pos] = ' '
    cantor(start,           seg, index + 1)
    cantor(start + seg * 2, seg, index + 1)
    return None

lines = ['*'] * (WIDTH*HEIGHT)
cantor(0, WIDTH, 1)

for i in xrange(HEIGHT):
    beg = WIDTH * i
    print ''.join(lines[beg : beg+WIDTH])
Task: Cantor set








VB: Module Module1

    Const WIDTH = 81
    Const HEIGHT = 5
    Dim lines(HEIGHT, WIDTH) As Char

    Sub Init()
        For i = 0 To HEIGHT - 1
            For j = 0 To WIDTH - 1
                lines(i, j) = "*"
            Next
        Next
    End Sub

    Sub Cantor(start As Integer, len As Integer, index As Integer)
        Dim seg As Integer = len / 3
        If seg = 0 Then
            Return
        End If
        For i = index To HEIGHT - 1
            For j = start + seg To start + seg * 2 - 1
                lines(i, j) = " "
            Next
        Next
        Cantor(start, seg, index + 1)
        Cantor(start + seg * 2, seg, index + 1)
    End Sub

    Sub Main()
        Init()
        Cantor(0, WIDTH, 1)
        For i = 0 To HEIGHT - 1
            For j = 0 To WIDTH - 1
                Console.Write(lines(i, j))
            Next
            Console.WriteLine()
        Next
    End Sub

End Module
Task: Cantor set




Go: package main

import "fmt"

const (
    width = 81
    height = 5
)

var lines [height][width]byte

func init() {
    for i := 0; i < height; i++ {
        for j := 0; j < width; j++ {
            lines[i][j] = '*'
        }
    }
}

func cantor(start, len, index int) {
    seg := len / 3
    if seg == 0 {
        return
    }
    for i := index; i < height; i++ {
        for j := start + seg; j < start + 2 * seg; j++ {
            lines[i][j] = ' '
        }
    }
    cantor(start, seg, index + 1)
    cantor(start + seg * 2, seg, index + 1)
}

func main() {
    cantor(0, width, 1)
    for _, line := range lines {
        fmt.Println(string(line[:]))
    }
}
Task: Cantor set

C: #include <stdio.h>

#define WIDTH 81
#define HEIGHT 5

char lines[HEIGHT][WIDTH];

void init() {
    int i, j;
    for (i = 0; i < HEIGHT; ++i) {
        for (j = 0; j < WIDTH; ++j) lines[i][j] = '*';
    }
}

void cantor(int start, int len, int index) {
    int i, j, seg = len / 3;
    if (seg == 0) return;
    for (i = index; i < HEIGHT; ++i) {
        for (j = start + seg; j < start + seg * 2; ++j) lines[i][j] = ' ';
    }
    cantor(start, seg, index + 1);
    cantor(start + seg * 2, seg, index + 1);
}

void print() {
    int i, j;
    for (i = 0; i < HEIGHT; ++i) {
        for (j = 0; j < WIDTH; ++j) printf("%c", lines[i][j]);
        printf("\n");
    }
}

int main() {
    init();
    cantor(0, WIDTH, 1);
    print();
    return 0;
}









COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. CANTOR.
       
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 SETTINGS.
          03 NUM-LINES     PIC 9 VALUE 5.
          03 FILL-CHAR     PIC X VALUE '#'.
       01 VARIABLES.
          03 CUR-LINE.
             05 CHAR       PIC X OCCURS 81 TIMES.
          03 WIDTH         PIC 99.
          03 CUR-SIZE      PIC 99.
          03 POS           PIC 99.
          03 MAXPOS        PIC 99.
          03 NEXTPOS       PIC 99.
          03 I             PIC 99.
          
       PROCEDURE DIVISION.
       BEGIN.
           COMPUTE WIDTH = 3 ** (NUM-LINES - 1).
           PERFORM INIT.
           MOVE WIDTH TO CUR-SIZE.
           DISPLAY CUR-LINE.
           PERFORM DO-LINE UNTIL CUR-SIZE IS EQUAL TO 1.
           STOP RUN.
           
       INIT.
           PERFORM INIT-CHAR VARYING I FROM 1 BY 1
                UNTIL I IS GREATER THAN WIDTH.
       
       INIT-CHAR.
           MOVE FILL-CHAR TO CHAR(I).
           
       DO-LINE.
           DIVIDE 3 INTO CUR-SIZE.
           MOVE 1 TO POS.
           SUBTRACT CUR-SIZE FROM WIDTH GIVING MAXPOS.
           PERFORM BLANK-REGIONS UNTIL POS IS GREATER THAN MAXPOS.
           DISPLAY CUR-LINE.
       
       BLANK-REGIONS.
           ADD CUR-SIZE TO POS.
           PERFORM BLANK-CHAR CUR-SIZE TIMES.
           
       BLANK-CHAR.
           MOVE SPACE TO CHAR(POS).
           ADD 1 TO POS.
Task: Cantor set



C#: using System;

namespace CantorSet {
    class Program {
        const int WIDTH = 81;
        const int HEIGHT = 5;
        private static char[,] lines = new char[HEIGHT, WIDTH];

        static Program() {
            for (int i = 0; i < HEIGHT; i++) {
                for (int j = 0; j < WIDTH; j++) {
                    lines[i, j] = '*';
                }
            }
        }

        private static void Cantor(int start, int len, int index) {
            int seg = len / 3;
            if (seg == 0) return;
            for (int i = index; i < HEIGHT; i++) {
                for (int j = start + seg; j < start + seg * 2; j++) {
                    lines[i, j] = ' ';
                }
            }
            Cantor(start, seg, index + 1);
            Cantor(start + seg * 2, seg, index + 1);
        }

        static void Main(string[] args) {
            Cantor(0, WIDTH, 1);
            for (int i = 0; i < HEIGHT; i++) {
                for (int j = 0; j < WIDTH; j++) {
                    Console.Write(lines[i,j]);
                }
                Console.WriteLine();
            }
        }
    }
}







COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. CANTOR.
       
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 SETTINGS.
          03 NUM-LINES     PIC 9 VALUE 5.
          03 FILL-CHAR     PIC X VALUE '#'.
       01 VARIABLES.
          03 CUR-LINE.
             05 CHAR       PIC X OCCURS 81 TIMES.
          03 WIDTH         PIC 99.
          03 CUR-SIZE      PIC 99.
          03 POS           PIC 99.
          03 MAXPOS        PIC 99.
          03 NEXTPOS       PIC 99.
          03 I             PIC 99.
          
       PROCEDURE DIVISION.
       BEGIN.
           COMPUTE WIDTH = 3 ** (NUM-LINES - 1).
           PERFORM INIT.
           MOVE WIDTH TO CUR-SIZE.
           DISPLAY CUR-LINE.
           PERFORM DO-LINE UNTIL CUR-SIZE IS EQUAL TO 1.
           STOP RUN.
           
       INIT.
           PERFORM INIT-CHAR VARYING I FROM 1 BY 1
                UNTIL I IS GREATER THAN WIDTH.
       
       INIT-CHAR.
           MOVE FILL-CHAR TO CHAR(I).
           
       DO-LINE.
           DIVIDE 3 INTO CUR-SIZE.
           MOVE 1 TO POS.
           SUBTRACT CUR-SIZE FROM WIDTH GIVING MAXPOS.
           PERFORM BLANK-REGIONS UNTIL POS IS GREATER THAN MAXPOS.
           DISPLAY CUR-LINE.
       
       BLANK-REGIONS.
           ADD CUR-SIZE TO POS.
           PERFORM BLANK-CHAR CUR-SIZE TIMES.
           
       BLANK-CHAR.
           MOVE SPACE TO CHAR(POS).
           ADD 1 TO POS.
Task: Cantor set


C++: #include <iostream>

const int WIDTH = 81;
const int HEIGHT = 5;

char lines[WIDTH*HEIGHT];

void cantor(int start, int len, int index) {
	int seg = len / 3;
	if (seg == 0) return;
	for (int i = index; i < HEIGHT; i++) {
		for (int j = start + seg; j < start + seg * 2; j++) {
			int pos = i * WIDTH + j;
			lines[pos] = ' ';
		}
	}
	cantor(start,           seg, index + 1);
	cantor(start + 2 * seg, seg, index + 1);
}

int main() {
	
	for (int i = 0; i < WIDTH*HEIGHT; i++) {
		lines[i] = '*';
	}

	
	cantor(0, WIDTH, 1);

	
	for (int i = 0; i < HEIGHT*WIDTH; i += WIDTH) {
		printf("%.*s\n", WIDTH, lines + i);
	}

	return 0;
}








COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. CANTOR.
       
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 SETTINGS.
          03 NUM-LINES     PIC 9 VALUE 5.
          03 FILL-CHAR     PIC X VALUE '#'.
       01 VARIABLES.
          03 CUR-LINE.
             05 CHAR       PIC X OCCURS 81 TIMES.
          03 WIDTH         PIC 99.
          03 CUR-SIZE      PIC 99.
          03 POS           PIC 99.
          03 MAXPOS        PIC 99.
          03 NEXTPOS       PIC 99.
          03 I             PIC 99.
          
       PROCEDURE DIVISION.
       BEGIN.
           COMPUTE WIDTH = 3 ** (NUM-LINES - 1).
           PERFORM INIT.
           MOVE WIDTH TO CUR-SIZE.
           DISPLAY CUR-LINE.
           PERFORM DO-LINE UNTIL CUR-SIZE IS EQUAL TO 1.
           STOP RUN.
           
       INIT.
           PERFORM INIT-CHAR VARYING I FROM 1 BY 1
                UNTIL I IS GREATER THAN WIDTH.
       
       INIT-CHAR.
           MOVE FILL-CHAR TO CHAR(I).
           
       DO-LINE.
           DIVIDE 3 INTO CUR-SIZE.
           MOVE 1 TO POS.
           SUBTRACT CUR-SIZE FROM WIDTH GIVING MAXPOS.
           PERFORM BLANK-REGIONS UNTIL POS IS GREATER THAN MAXPOS.
           DISPLAY CUR-LINE.
       
       BLANK-REGIONS.
           ADD CUR-SIZE TO POS.
           PERFORM BLANK-CHAR CUR-SIZE TIMES.
           
       BLANK-CHAR.
           MOVE SPACE TO CHAR(POS).
           ADD 1 TO POS.
Task: Cantor set





Java: public class App {
    private static final int WIDTH = 81;
    private static final int HEIGHT = 5;

    private static char[][] lines;
    static {
        lines = new char[HEIGHT][WIDTH];
        for (int i = 0; i < HEIGHT; i++) {
            for (int j = 0; j < WIDTH; j++) {
                lines[i][j] = '*';
            }
        }
    }

    private static void cantor(int start, int len, int index) {
        int seg = len / 3;
        if (seg == 0) return;
        for (int i = index; i < HEIGHT; i++) {
            for (int j = start + seg; j < start + seg * 2; j++) {
                lines[i][j] = ' ';
            }
        }
        cantor(start, seg, index + 1);
        cantor(start + seg * 2, seg, index + 1);
    }

    public static void main(String[] args) {
        cantor(0, WIDTH, 1);
        for (int i = 0; i < HEIGHT; i++) {
            for (int j = 0; j < WIDTH; j++) {
                System.out.print(lines[i][j]);
            }
            System.out.println();
        }
    }
}





COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. CANTOR.
       
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 SETTINGS.
          03 NUM-LINES     PIC 9 VALUE 5.
          03 FILL-CHAR     PIC X VALUE '#'.
       01 VARIABLES.
          03 CUR-LINE.
             05 CHAR       PIC X OCCURS 81 TIMES.
          03 WIDTH         PIC 99.
          03 CUR-SIZE      PIC 99.
          03 POS           PIC 99.
          03 MAXPOS        PIC 99.
          03 NEXTPOS       PIC 99.
          03 I             PIC 99.
          
       PROCEDURE DIVISION.
       BEGIN.
           COMPUTE WIDTH = 3 ** (NUM-LINES - 1).
           PERFORM INIT.
           MOVE WIDTH TO CUR-SIZE.
           DISPLAY CUR-LINE.
           PERFORM DO-LINE UNTIL CUR-SIZE IS EQUAL TO 1.
           STOP RUN.
           
       INIT.
           PERFORM INIT-CHAR VARYING I FROM 1 BY 1
                UNTIL I IS GREATER THAN WIDTH.
       
       INIT-CHAR.
           MOVE FILL-CHAR TO CHAR(I).
           
       DO-LINE.
           DIVIDE 3 INTO CUR-SIZE.
           MOVE 1 TO POS.
           SUBTRACT CUR-SIZE FROM WIDTH GIVING MAXPOS.
           PERFORM BLANK-REGIONS UNTIL POS IS GREATER THAN MAXPOS.
           DISPLAY CUR-LINE.
       
       BLANK-REGIONS.
           ADD CUR-SIZE TO POS.
           PERFORM BLANK-CHAR CUR-SIZE TIMES.
           
       BLANK-CHAR.
           MOVE SPACE TO CHAR(POS).
           ADD 1 TO POS.
Task: Cantor set







Python: WIDTH = 81
HEIGHT = 5

lines=[]
def cantor(start, len, index):
    seg = len / 3
    if seg == 0:
        return None
    for it in xrange(HEIGHT-index):
        i = index + it
        for jt in xrange(seg):
            j = start + seg + jt
            pos = i * WIDTH + j
            lines[pos] = ' '
    cantor(start,           seg, index + 1)
    cantor(start + seg * 2, seg, index + 1)
    return None

lines = ['*'] * (WIDTH*HEIGHT)
cantor(0, WIDTH, 1)

for i in xrange(HEIGHT):
    beg = WIDTH * i
    print ''.join(lines[beg : beg+WIDTH])



COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. CANTOR.
       
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 SETTINGS.
          03 NUM-LINES     PIC 9 VALUE 5.
          03 FILL-CHAR     PIC X VALUE '#'.
       01 VARIABLES.
          03 CUR-LINE.
             05 CHAR       PIC X OCCURS 81 TIMES.
          03 WIDTH         PIC 99.
          03 CUR-SIZE      PIC 99.
          03 POS           PIC 99.
          03 MAXPOS        PIC 99.
          03 NEXTPOS       PIC 99.
          03 I             PIC 99.
          
       PROCEDURE DIVISION.
       BEGIN.
           COMPUTE WIDTH = 3 ** (NUM-LINES - 1).
           PERFORM INIT.
           MOVE WIDTH TO CUR-SIZE.
           DISPLAY CUR-LINE.
           PERFORM DO-LINE UNTIL CUR-SIZE IS EQUAL TO 1.
           STOP RUN.
           
       INIT.
           PERFORM INIT-CHAR VARYING I FROM 1 BY 1
                UNTIL I IS GREATER THAN WIDTH.
       
       INIT-CHAR.
           MOVE FILL-CHAR TO CHAR(I).
           
       DO-LINE.
           DIVIDE 3 INTO CUR-SIZE.
           MOVE 1 TO POS.
           SUBTRACT CUR-SIZE FROM WIDTH GIVING MAXPOS.
           PERFORM BLANK-REGIONS UNTIL POS IS GREATER THAN MAXPOS.
           DISPLAY CUR-LINE.
       
       BLANK-REGIONS.
           ADD CUR-SIZE TO POS.
           PERFORM BLANK-CHAR CUR-SIZE TIMES.
           
       BLANK-CHAR.
           MOVE SPACE TO CHAR(POS).
           ADD 1 TO POS.
Task: Cantor set








VB: Module Module1

    Const WIDTH = 81
    Const HEIGHT = 5
    Dim lines(HEIGHT, WIDTH) As Char

    Sub Init()
        For i = 0 To HEIGHT - 1
            For j = 0 To WIDTH - 1
                lines(i, j) = "*"
            Next
        Next
    End Sub

    Sub Cantor(start As Integer, len As Integer, index As Integer)
        Dim seg As Integer = len / 3
        If seg = 0 Then
            Return
        End If
        For i = index To HEIGHT - 1
            For j = start + seg To start + seg * 2 - 1
                lines(i, j) = " "
            Next
        Next
        Cantor(start, seg, index + 1)
        Cantor(start + seg * 2, seg, index + 1)
    End Sub

    Sub Main()
        Init()
        Cantor(0, WIDTH, 1)
        For i = 0 To HEIGHT - 1
            For j = 0 To WIDTH - 1
                Console.Write(lines(i, j))
            Next
            Console.WriteLine()
        Next
    End Sub

End Module


COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. CANTOR.
       
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 SETTINGS.
          03 NUM-LINES     PIC 9 VALUE 5.
          03 FILL-CHAR     PIC X VALUE '#'.
       01 VARIABLES.
          03 CUR-LINE.
             05 CHAR       PIC X OCCURS 81 TIMES.
          03 WIDTH         PIC 99.
          03 CUR-SIZE      PIC 99.
          03 POS           PIC 99.
          03 MAXPOS        PIC 99.
          03 NEXTPOS       PIC 99.
          03 I             PIC 99.
          
       PROCEDURE DIVISION.
       BEGIN.
           COMPUTE WIDTH = 3 ** (NUM-LINES - 1).
           PERFORM INIT.
           MOVE WIDTH TO CUR-SIZE.
           DISPLAY CUR-LINE.
           PERFORM DO-LINE UNTIL CUR-SIZE IS EQUAL TO 1.
           STOP RUN.
           
       INIT.
           PERFORM INIT-CHAR VARYING I FROM 1 BY 1
                UNTIL I IS GREATER THAN WIDTH.
       
       INIT-CHAR.
           MOVE FILL-CHAR TO CHAR(I).
           
       DO-LINE.
           DIVIDE 3 INTO CUR-SIZE.
           MOVE 1 TO POS.
           SUBTRACT CUR-SIZE FROM WIDTH GIVING MAXPOS.
           PERFORM BLANK-REGIONS UNTIL POS IS GREATER THAN MAXPOS.
           DISPLAY CUR-LINE.
       
       BLANK-REGIONS.
           ADD CUR-SIZE TO POS.
           PERFORM BLANK-CHAR CUR-SIZE TIMES.
           
       BLANK-CHAR.
           MOVE SPACE TO CHAR(POS).
           ADD 1 TO POS.