Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
krkris
/
Loogikafunktsioon
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7c767e7f
authored
Apr 25, 2022
by
erfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update .gitignore
parent
30929c62
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
710 deletions
.gitignore
.gitignore
View file @
7c767e7f
#include <stdio.h>
# Prerequisites
#include <string.h>
*.d
#include <stdbool.h>
#include <stdlib.h>
# Object files
// kood kommenteerida, muutujate nimed, funktsioonide lisamine
*.o
*.ko
// STRUCT
*.obj
*.elf
typedef struct{
char kood[5];
# Linker output
bool kleebitud;
*.ilk
bool lihtimplikant;
*.map
}implikandid; // kleepimata implikandid
*.exp
typedef struct{
# Precompiled Headers
char kood[5];
*.gch
bool kleebitud;
*.pch
bool lihtimplikant;
}implikandid2; // 1.kleepimise tulemus
# Libraries
*.lib
typedef struct{
*.a
char kood[5];
*.la
bool kleebitud;
*.lo
bool lihtimplikant;
}implikandid3; // 2.kleepimise tulemus
# Shared objects (inc. Windows DLLs)
*.dll
typedef struct{
*.so
char kood[5];
*.so.*
}implikandid4; // 3.kleepimise tulemus
*.dylib
# Executables
// FUNKTSIOONIDE PROTOTÜÜBID
*.exe
int kontroll(char[]);
*.out
int sisestus(const char[], char[], char[], char[], char[]);
*.app
void info(char, char, char, char, char, char, char, char, char, char, char, char, char, char, char, char);
*.i*86
void kontuur(char, char, char, char, char, char, char, char, char, char, char, char, char, char, char, char);
*.x86_64
*.hex
// MAIN
# Debug files
int main(void){
*.dSYM/
char a[16], b[16], c[16], d[16];
*.su
char f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, fA, fB, fC, fD, fE, fF;
*.idb
int input;
*.pdb
input = sisestus("Sisestage 4x4 Karnaugh kaart voi 16 loogikavaartust: \n", a, b, c, d);
if (input == 1){
# Kernel Module Compile Results
return 1;
*.mod*
}
*.cmd
if (strlen(a) >= 16){
.tmp_versions/
f0 = a[0];
modules.order
f1 = a[1];
Module.symvers
f2 = a[2];
Mkfile.old
f3 = a[3];
dkms.conf
f4 = a[4];
f5 = a[5];
f6 = a[6];
f7 = a[7];
f8 = a[8];
f9 = a[9];
fA = a[10];
fB = a[11];
fC = a[12];
fD = a[13];
fE = a[14];
fF = a[15];
}
else{
f0 = a[0];
f1 = a[1];
f2 = a[3];
f3 = a[2];
f4 = b[0];
f5 = b[1];
f6 = b[3];
f7 = b[2];
f8 = d[0];
f9 = d[1];
fA = d[3];
fB = d[2];
fC = c[0];
fD = c[1];
fE = c[3];
fF = c[2];
}
info(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, fA, fB, fC, fD, fE, fF);
kontuur(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, fA, fB, fC, fD, fE, fF);
return 0;
}
// FUNKTSIOONIDE KIRJELDUSED
// Kasutaja sisestatu kontrollimine:
int kontroll(char a[16]){
int i;
for (i = 0; i < strlen(a); i++){
if (a[i] != '0' && a[i] != '1'){
printf("Lubamatu sisend: %s\n", a);
return 1;
}
}
if (strlen(a) != 4){
printf("Lubamatu sisend %s\n", a);
return 1;
}
return 0;
}
// Kasutaja loogikaväärtuste sisestus:
int sisestus(const char tekst[40], char a[16], char b[16], char c[16], char d[16]){
int i;
printf("%s", tekst);
scanf("%s", a);
for (i = 0; i < strlen(a); i++){
if (a[i] != '0' && a[i] != '1'){
printf("Lubamatu sisend: %s\n", a);
return 1;
}
}
if (strlen(a) == 4){
do{
printf("\n%s\n", a);
printf("Sisestage K-kaardi TEINE rida: \n");
scanf("%s", b);
}while(kontroll(b) == 1);
do{
printf("\n%s\n", a);
printf("%s\n", b);
printf("Sisestage K-kaardi KOLMAS rida: \n");
scanf("%s", c);
}while(kontroll(c) == 1);
do{
printf("\n%s\n", a);
printf("%s\n", b);
printf("%s\n", c);
printf("Sisestage K-kaardi NELJAS rida: \n");
scanf("%s", d);
}while(kontroll(d) == 1);
printf("\n");
printf("\nTerviklik kaart:\n");
for (i = 0; i < strlen(a); i++){
printf("%c ", a[i]);
}
printf("\n");
for (i = 0; i < strlen(b); i++){
printf("%c ", b[i]);
}
printf("\n");
for (i = 0; i < strlen(c); i++){
printf("%c ", c[i]);
}
printf("\n");
for (i = 0; i < strlen(d); i++){
printf("%c ", d[i]);
}
printf("\n");
}
else if (strlen(a) >= 16){
for (i = 0; i < 16; i++){
if (a[i] != '0' && a[i] != '1'){
printf("\nLubamatu sisend: %s\n", a);
return 1;
}
}
printf("\n");
printf("\nK-kaardi kujul:\n");
printf("%c %c %c %c\n", a[0], a[1], a[3], a[2]);
printf("%c %c %c %c\n", a[4], a[5], a[7], a[6]);
printf("%c %c %c %c\n", a[12], a[13], a[15], a[14]);
printf("%c %c %c %c\n", a[8], a[9], a[11], a[10]);
}
else{ // Kui kasutaja sisestab mittesobiva märkide arvu, siis programm teeb exit.
printf("Lubamatu sisend: %s\n", a);
return 1;
}
return 0;
}
// Reed-Mulleri polünoomi kujul oleva loogikafunktsiooni kohta info andmine:
void info(char f0, char f1, char f2, char f3, char f4, char f5, char f6, char f7, char f8, char f9, char fA, char fB, char fC, char fD, char fE, char fF){
if (f0 == '1'){
printf("Konstant 1 olemas\n");
}
else{
printf("Konstant 1 puudub\n");
}
if (fF == '1'){
printf("PAARITU arv liikmeid\n");
}
else{
printf("PAARISarv liikmeid\n");
}
if (f0 == f8){
printf("x1 puudub\n");
}
else{
printf("x1 olemas\n");
}
if (f0 == f4){
printf("x2 puudub\n");
}
else{
printf("x2 olemas\n");
}
if (f0 == f2){
printf("x3 puudub\n");
}
else{
printf("x3 olemas\n");
}
if (f0 == f1){
printf("x4 puudub\n");
}
else{
printf("x4 olemas\n");
}
if (f7 == '1'){
printf("ilma [x1] PAARITU\n");
}
else{
printf("ilma [x1] PAARIS\n");
}
if (fB == '1'){
printf("ilma [x2] PAARITU\n");
}
else{
printf("ilma [x2] PAARIS\n");
}
if (fD == '1'){
printf("ilma [x3] PAARITU\n");
}
else{
printf("ilma [x3] PAARIS\n");
}
if (fE == '1'){
printf("ilma [x4] PAARITU\n");
}
else{
printf("ilma [x4] PAARIS\n");
} // info funktsiooni lõpp siin
}
// Kontuuride leidmine
void kontuur(char f0, char f1, char f2, char f3, char f4, char f5, char f6, char f7, char f8, char f9, char fA, char fB, char fC, char fD, char fE, char fF){
implikandid implikant[16];
int i = 0;
int j, k;
if(f0 == '1'){
strcpy(implikant[i].kood, "0000");
i++;
}
if(f1 == '1'){
strcpy(implikant[i].kood, "0001");
i++;
}
if(f2 == '1'){
strcpy(implikant[i].kood, "0010");
i++;
}
if(f3 == '1'){
strcpy(implikant[i].kood, "0011");
i++;
}
if(f4 == '1'){
strcpy(implikant[i].kood, "0100");
i++;
}
if(f5 == '1'){
strcpy(implikant[i].kood, "0101");
i++;
}
if(f6 == '1'){
strcpy(implikant[i].kood, "0110");
i++;
}
if(f7 == '1'){
strcpy(implikant[i].kood, "0111");
i++;
}
if(f8 == '1'){
strcpy(implikant[i].kood, "1000");
i++;
}
if(f9 == '1'){
strcpy(implikant[i].kood, "1001");
i++;
}
if(fA == '1'){
strcpy(implikant[i].kood, "1010");
i++;
}
if(fB == '1'){
strcpy(implikant[i].kood, "1011");
i++;
}
if(fC == '1'){
strcpy(implikant[i].kood, "1100");
i++;
}
if(fD == '1'){
strcpy(implikant[i].kood, "1101");
i++;
}
if(fE == '1'){
strcpy(implikant[i].kood, "1110");
i++;
}
if(fF == '1'){
strcpy(implikant[i].kood, "1111");
i++;
}
int eri = 0;
implikandid2 implikant2[16];
int q;
int t = 0;
int o;
printf("Esimese kleepimise tulemus: \n");
for (j = 0; j < i; j++){
for (k = 0; k < i; k++){
if(implikant[j].kood[0] != implikant[k].kood[0]){
eri++;
q = 0;
}
if (implikant[j].kood[1] != implikant[k].kood[1]){
eri++;
q = 1;
}
if (implikant[j].kood[2] != implikant[k].kood[2]){
eri++;
q = 2;
}
if (implikant[j].kood[3] != implikant[k].kood[3]){
eri++;
q = 3;
}
if (eri == 1){
if (q == 0){
strcpy(implikant2[t].kood, implikant[j].kood); // des, source
implikant2[t].kood[q] = '-';
}
if (q == 1){
strcpy(implikant2[t].kood, implikant[j].kood);
implikant2[t].kood[q] = '-';
}
if (q == 2){
strcpy(implikant2[t].kood, implikant[j].kood);
implikant2[t].kood[q] = '-';
}
if (q == 3){
strcpy(implikant2[t].kood, implikant[j].kood);
implikant2[t].kood[q] = '-';
}
implikant[j].kleebitud = true;
t++;
}
eri = 0;
}
}
for(j=0; j<t; j++){
for(k=j+1; k<t; k++){
if(strcmp(implikant2[j].kood, implikant2[k].kood) == 0){
for(o = k; o<t-1; o++){
strcpy(implikant2[o].kood, implikant2[o+1].kood);
}
t--;
j--;
}
}
}
for(j = 0; j<t; j++){
printf("%s\n", implikant2[j].kood);
}
printf("\n");
printf("\n");
printf("\n");
implikandid3 implikant3[16];
int v = 0;
printf("Teise kleepimise tulemus: \n");
for (j = 0; j < t; j++){
for (k = 0; k < t; k++){
if (implikant2[j].kood[0] != implikant2[k].kood[0]){
eri++;
q = 0;
}
if (implikant2[j].kood[1] != implikant2[k].kood[1]){
eri++;
q = 1;
}
if (implikant2[j].kood[2] != implikant2[k].kood[2]){
eri++;
q = 2;
}
if (implikant2[j].kood[3] != implikant2[k].kood[3]){
eri++;
q = 3;
}
if (eri == 1){
if (q == 0){
strcpy(implikant3[v].kood, implikant2[j].kood);
implikant3[v].kood[q] = '-';
}
if (q == 1){
strcpy(implikant3[v].kood, implikant2[j].kood);
implikant3[v].kood[q] = '-';
}
if (q == 2){
strcpy(implikant3[v].kood, implikant2[j].kood);
implikant3[v].kood[q] = '-';
}
if (q == 3){
strcpy(implikant3[v].kood, implikant2[j].kood);
implikant3[v].kood[q] = '-';
}
implikant2[j].kleebitud = true;
v++;
}
eri = 0;
}
}
for(j=0; j<v; j++){
for(k=j+1; k<v; k++){
if(strcmp(implikant3[j].kood, implikant3[k].kood) == 0){
for(o = k; o<v-1; o++){
strcpy(implikant3[o].kood, implikant3[o+1].kood);
}
v--;
j--;
}
}
}
for(j = 0; j<v; j++){
printf("%s\n", implikant3[j].kood);
}
printf("\n");
printf("\n");
printf("\n");
implikandid4 implikant4[16];
int r = 0;
printf("Kolmanda kleepimise tulemus: \n");
for (j = 0; j < v; j++){
for (k = 0; k < v; k++){
if (implikant3[j].kood[0] != implikant3[k].kood[0]){
eri++;
q = 0;
}
if (implikant3[j].kood[1] != implikant3[k].kood[1]){
eri++;
q = 1;
}
if (implikant3[j].kood[2] != implikant3[k].kood[2]){
eri++;
q = 2;
}
if (implikant3[j].kood[3] != implikant3[k].kood[3]){
eri++;
q = 3;
}
if (eri == 1){
if (q == 0){
strcpy(implikant4[r].kood, implikant3[j].kood);
implikant3[r].kood[q] = '-';
}
if (q == 1){
strcpy(implikant4[r].kood, implikant3[j].kood);
implikant4[r].kood[q] = '-';
}
if (q == 2){
strcpy(implikant4[r].kood, implikant3[j].kood);
implikant4[r].kood[q] = '-';
}
if (q == 3){
strcpy(implikant4[r].kood, implikant3[j].kood);
implikant4[r].kood[q] = '-';
}
implikant3[j].kleebitud = true;
r++;
}
eri = 0;
}
}
printf("\n");
printf("Pärast kustutamist: \n");
for(j=0; j<r; j++){
for(k=j+1; k<r; k++){
if(strcmp(implikant4[j].kood, implikant4[k].kood) == 0){
for(o = k; o<r-1; o++){
strcpy(implikant4[o].kood, implikant4[o+1].kood);
}
r--;
j--;
}
}
}
for(j = 0; j<r; j++){
printf("%s\n", implikant4[j].kood);
}
printf("\n");
printf("\n");
printf("\n");
printf("Lihtimplikandid: \n");
for(j = 0; j<i; j++){
if(implikant[j].kleebitud != true){
printf("%s\n", implikant[j].kood);
}
}
for(j = 0; j<t; j++){
if(implikant2[j].kleebitud != true){
printf("%s\n", implikant2[j].kood);
}
}
for(j = 0; j<v; j++){
if(implikant3[j].kleebitud != true){
printf("%s\n", implikant3[j].kood);
}
}
for(j = 0; j<r; j++){
printf("%s\n", implikant4[j].kood);
}
printf("\n");
printf("\n");
printf("\n");
// Lihtimplikantide disjunktsiooni loomine, loogikamuutujate vastavaks seadmine TaDNK jaoks
printf("TaDNK:\n");
int m;
char indeks[10];
char tulemus[50];
int z = -1;
for(j = 0; j<i; j++){
if(implikant[j].kleebitud != true){
for (m = 0; m < 4; m++){
if (implikant[j].kood[m] == '0'){
z++;
tulemus[z] = '-';
z++;
tulemus[z] = 'X';
z++;
sprintf(indeks, "%d", m+1);
tulemus[z] = indeks[0];
}
else if (implikant[j].kood[m] == '1'){
z++;
tulemus[z] = 'X';
z++;
sprintf(indeks, "%d", m+1);
tulemus[z] = indeks[0];
}
if (m == 3){
z++;
tulemus[z] = '\t';
z++;
tulemus[z] = 'V';
z++;
tulemus[z] = '\t';
}
}
}
}
for(j = 0; j < t; j++){
if(implikant2[j].kleebitud != true){
for (m = 0; m < 4; m++){
if (implikant2[j].kood[m] == '0'){
z++;
tulemus[z] = '-';
z++;
tulemus[z] = 'X';
z++;
sprintf(indeks, "%d", m+1);
tulemus[z] = indeks[0];
}
else if (implikant2[j].kood[m] == '1'){
z++;
tulemus[z] = 'X';
z++;
sprintf(indeks, "%d", m+1);
tulemus[z] = indeks[0];
}
if (m == 3){
z++;
tulemus[z] = '\t';
z++;
tulemus[z] = 'V';
z++;
tulemus[z] = '\t';
}
}
}
}
for(j = 0; j < v; j++){
if(implikant3[j].kleebitud != true){
for (m = 0; m < 4; m++){
if (implikant3[j].kood[m] == '0'){
z++;
tulemus[z] = '-';
z++;
tulemus[z] = 'X';
z++;
sprintf(indeks, "%d", m+1);
tulemus[z] = indeks[0];
}
else if (implikant3[j].kood[m] == '1'){
z++;
tulemus[z] = 'X';
z++;
sprintf(indeks, "%d", m+1);
tulemus[z] = indeks[0];
}
if (m == 3){
z++;
tulemus[z] = '\t';
z++;
tulemus[z] = 'V';
z++;
tulemus[z] = '\t';
}
}
}
}
for(j = 0; j < r; j++){
for (m = 0; m < 4; m++){
if (implikant4[j].kood[m] == '0'){
z++;
tulemus[z] = '-';
z++;
tulemus[z] = 'X';
z++;
sprintf(indeks, "%d", m+1);
tulemus[z] = indeks[0];
}
else if (implikant4[j].kood[m] == '1'){
z++;
tulemus[z] = 'X';
z++;
sprintf(indeks, "%d", m+1);
tulemus[z] = indeks[0];
}
if (m == 3){
z++;
tulemus[z] = '\t';
z++;
tulemus[z] = 'V';
z++;
tulemus[z] = '\t';
}
}
}
// TaDNK välja printimine
tulemus[z-1] = ' ';
printf("%s", tulemus);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment