Алгоритм множества Кантора на C++


#include "stdafx.h"
#include <iostream>
using namespace std;

const int Width = 81;
const int Height = 5;
char Simvol = 221;
char massiv[Height][Width];

void KantorR(int begin, int size, int count);

int _tmain(int argc, _TCHAR* argv[])
{
for (int i = 0; i<Height; i++) {
for (int j = 0; j<Width; j++)
{
massiv[i][j] = Simvol;
}
}
KantorR(0, Width, 1);
for (int i = 0; i<Height; i++) {
for (int j = 0; j<Width; j++) {
cout<<massiv[i][j];
}
cout<<endl;
}
system("pause");
return 0;
}

void KantorR(int begin, int size, int count) {
int i, j, section=size/3;
if (section==0)
{
return;
}
for (i=count; i<Height; i++)
{
for (j=begin+section; j<begin+section*2; j++) massiv[i][j] = ' ';
}
KantorR(begin, section, count+1);
KantorR(begin+2*section, section, count+1);
}

Результат работы программы множества Кантора на C++:

множество Кантора на C++

1148

Leave a Reply

Ваш адрес email не будет опубликован.