Created
December 21, 2018 14:30
-
-
Save dertst/3345276cb12dd4c7f7c93da0a23e0c18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include"stdio.h" | |
#include "pch.h" | |
#include <iostream> | |
#include"string" | |
#include "conio.h" | |
#include "Windows.h" | |
int main() | |
{ | |
//кодирование | |
int num[4]; | |
int encode[7]; | |
int sind[3]; | |
int tmp; | |
for (int i = 0; i < 4; i++) | |
{ | |
scanf_s("%d", &num[i]); | |
} | |
for (int i = 0; i < 4; i++) | |
{ | |
encode[i]=num[i]; | |
} | |
encode[4] = (encode[0] + encode[1] + encode[2]) % 2; | |
encode[5] = (encode[1] + encode[2] + encode[3]) % 2; | |
encode[6] = (encode[0] + encode[1] + encode[3]) % 2; | |
sind[1] = (encode[4] + encode[0] + encode[1] + encode[2]) % 2; | |
sind[2] = (encode[5] + encode[1] + encode[3] + encode[2]) % 2; | |
sind[3] = (encode[6] + encode[0] + encode[1] + encode[3]) % 2; | |
//шифрование | |
encode[6] = encode[3]; | |
encode[5] = encode[2]; | |
encode[4] = encode[1]; | |
encode[3] = 0; | |
encode[2] = encode[0]; | |
encode[1] = 0; | |
encode[0] = 0; | |
int mat[4][7]; | |
int i=0; | |
for (int j = 0; j < 7; j++) | |
{ | |
mat[i][j] = encode[j]; | |
} | |
i++; | |
for (int j = 0; j < 7; j++) | |
{ | |
if ((j%2) == 0) | |
{ | |
mat[i][j] = 1; | |
} | |
else | |
{ | |
mat[i][j] = 0; | |
} | |
} | |
i++; | |
mat[i][0] = 0; | |
for (int j = 1; j < 7; j+=4) | |
{ | |
mat[i][j] = 1; | |
mat[i][j + 1] = 1; | |
} | |
for (int j = 3; j < 7; j += 4) | |
{ | |
mat[i][j] = 0; | |
mat[i][j + 1] = 0; | |
} | |
i++; | |
for (int j = 0; j < 3; j++) | |
{ | |
mat[i][j] = 0; | |
} | |
for (int j = 3; j < 7; j++) | |
{ | |
mat[i][j] = 1; | |
} | |
for (int i = 0; i < 4; i++) | |
{ | |
for (int j = 0; j < 7; j++) | |
{ | |
printf("%d", mat[i][j]); | |
} | |
printf("\n"); | |
} | |
Sleep(10000000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment