Commit 36492c5d by erfeld

Add new file

parent b9c77b18
Showing with 250 additions and 0 deletions
#include <stdio.h>
#include <string.h>
int kontroll(char b[16]){
int i;
for (i = 0; i < strlen(b); i++){
if (b[i] != '0' && b[i] != '1'){
return 1;
}
}
if (strlen(b) != 4){
return 1;
}
return 0;
}
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){
/*printf("\n%s\n", a);
printf("Sisestage K-kaardi TEINE rida \n");
scanf("%s", b);*/
do{
printf("\n%s\n", a);
printf("Sisestage K-kaardi TEINE rida \n");
scanf("%s", b);
}while(kontroll(b) == 1);
printf("\n%s\n", a);
printf("%s\n", b);
printf("Sisestage K-kaardi KOLMAS rida \n");
scanf("%s", c);
do{
printf("Lubamatu sisend: %s", c);
printf("\n%s\n", a);
printf("%s\n", b);
printf("Sisestage K-kaardi KOLMAS rida \n");
scanf("%s", c);
}while(kontroll(c) == 1);
printf("\n%s\n", a);
printf("%s\n", b);
printf("%s\n", c);
printf("Sisestage K-kaardi NELJAS rida \n");
scanf("%s", d);
do{
printf("Lubamatu sisend: %s", d);
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("\nTerviklik kaart:\n");
printf("\n%s\n", a);
printf("%s\n", b);
printf("%s\n", c);
printf("%s\n", d);
}
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;
}
}
}
else{ // Kui kasutaja sisestab mittesobiva märkide arvu, siis programm teeb exit.
printf("Lubamatu sisend: %s", a);
return 1;
}
return 0;
}
/*char array[4][4] = {{
a[20],
b[20],
c[20],
d[20]
}};
int j;
for (i = 0; i < 4; i++){
for (j = 0; j < 4; j++){
printf("%c", array[i][j]);
}
}*/
void info(char a[16], char b[16], char c[16], char d[16]){
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 (strlen(a) >= 16){
f0 = a[0];
f1 = a[1];
f2 = a[3];
f3 = a[2];
f4 = a[4];
f5 = a[5];
f6 = a[7];
f7 = a[6];
f8 = a[12];
f9 = a[13];
fA = a[15];
fB = a[14];
fC = a[8];
fD = a[9];
fE = a[11];
fF = a[10];
}
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 = c[0];
f9 = c[1];
fA = c[3];
fB = c[2];
fC = d[0];
fD = d[1];
fE = d[3];
fF = d[2];
}
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");
}
}
int main(void){
char a[16], b[16], c[16], d[16];
int input;
input = sisestus("Sisestage 4x4 Karnaugh kaart voi 16 loogikavaartust: \n", a, b, c, d);
kontroll(a);
if (input == 1){
return 1;
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment