#include "pch.h"
#include <iostream>
#include <windows.h>
#include <stdio.h>
#include <cmath>
#include <string>
#include <fstream>
using namespace std;
int main()
{
setlocale(LC_ALL, "rus");
int size;
cout << "Сколько битов информации? Ввод:";
cin >> size;
char* buffer = new char[size + 1]; buffer[size] = 0;
cout << "Отправленная информация(двоичная система)=";
cin >> buffer;
char c;
int x = 0;
int g;
int m[256];
int number[256];
int num = 0;
for (int i = 0; i < size; i++)
{
c = buffer[i];
g = c;
x = g - 48;
m[i] = x;
if (m[i] == 1)
{
number[num] = i;
cout << "number " << " " << number[num];
num++;
}
}
cout << endl;
int kosybas[7] = { 0, 3, 6, 1, 5, 4, 2};
int kosy[7][7];
int gg;
for (int i = 0; i < 7; i++)
{
for (int j = i; j < 7; j++)
{
if (i == j)
{
kosy[i][j] = 0;
continue;
}
if (i == 0)
{
kosy[i][j] = kosybas[j];
kosy[j][i] = kosy[i][j];
continue;
}
gg=kosy[i - 1][j - 1] + 1;
while (gg >= 7)
{
gg = gg - 7;
}
kosy[i][j] = gg;
kosy[j][i] = kosy[i][j];
}
}
for (int i = 0; i < 7; i++)
{
for (int j = 0; j < 7; j++)
{
cout << kosy[i][j];
}
cout << endl;
}
int w,t,s;
int p=10;
int a = 0;
int d = 1;
int G[256];
for (int i = 0; i < size; i++)
{
for (int j = 0; j < num; j++)
{
w = number[j];
if (w == 0)
{
continue;
}
w = w * i;
while (w >= 7)
{
w = w - 7;
}
if (p == 10)
{
p = w;
continue;
}
if (p != 10)
{
if (kosy[p][w] == 0)
{
d ++;
a = 1;
p = 1;
continue;
}
if (p == w)
{
a = 0;
p = 0;
continue;
}
a = kosy[p][w];
p = a;
}
}
p = 10;
while (a >= 7)
{
a = a - 7;
}
s = a;
if (d % 2 == 0)
{
s = 0;
}
for (int j = 0; j < num; j++)
{
t = number[j];
if (t == 0)
{
a = kosybas[s];
}
}
G[i] = a;
d = 1;
a = 0;
}
G[i] = a;
d = 1;
a = 0;
}
for (int i = 0; i < size; i++)
{
cout << "G[" << i << "]=" << G[i] << endl;
}
}