Commit b350b665 by erfeld

Update .c

parent da9a894f
Showing with 9 additions and 24 deletions
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
int kontroll(char b[16]){ int kontroll(char a[16]){
int i; int i;
for (i = 0; i < strlen(b); i++){ for (i = 0; i < strlen(a); i++){
if (b[i] != '0' && b[i] != '1'){ if (a[i] != '0' && a[i] != '1'){
printf("Lubamatu sisend\n");
return 1; return 1;
} }
} }
if (strlen(b) != 4){ if (strlen(a) != 4){
printf("Lubamatu sisend\n");
return 1; return 1;
} }
return 0; return 0;
} }
int sisestus(const char tekst[40], char a[16], char b[16], char c[16], char d[16]){ int sisestus(const char tekst[40], char a[16], char b[16], char c[16], char d[16]){
int i; int i;
printf("%s", tekst); printf("%s", tekst);
...@@ -27,44 +26,30 @@ int sisestus(const char tekst[40], char a[16], char b[16], char c[16], char d[16 ...@@ -27,44 +26,30 @@ int sisestus(const char tekst[40], char a[16], char b[16], char c[16], char d[16
return 1; return 1;
} }
} }
if (strlen(a) == 4){ if (strlen(a) == 4){
/*printf("\n%s\n", a);
printf("Sisestage K-kaardi TEINE rida \n");
scanf("%s", b);*/
do{ do{
printf("\n%s\n", a); printf("\n%s\n", a);
printf("Sisestage K-kaardi TEINE rida \n"); printf("Sisestage K-kaardi TEINE rida \n");
scanf("%s", b); scanf("%s", b);
}while(kontroll(b) == 1); }while(kontroll(b) == 1);
printf("\n%s\n", a); printf("\n%s\n", a);
printf("%s\n", b); printf("%s\n", b);
printf("Sisestage K-kaardi KOLMAS rida \n");
scanf("%s", c);
do{ do{
printf("Lubamatu sisend: %s", c);
printf("\n%s\n", a); printf("\n%s\n", a);
printf("%s\n", b); printf("%s\n", b);
printf("Sisestage K-kaardi KOLMAS rida \n"); printf("Sisestage K-kaardi KOLMAS rida \n");
scanf("%s", c); scanf("%s", c);
}while(kontroll(c) == 1); }while(kontroll(c) == 1);
printf("\n%s\n", a); printf("\n%s\n", a);
printf("%s\n", b); printf("%s\n", b);
printf("%s\n", c); printf("%s\n", c);
printf("Sisestage K-kaardi NELJAS rida \n");
scanf("%s", d);
do{ do{
printf("Lubamatu sisend: %s", d);
printf("\n%s\n", a); printf("\n%s\n", a);
printf("%s\n", b); printf("%s\n", b);
printf("%s\n", c); printf("%s\n", c);
printf("Sisestage K-kaardi NELJAS rida \n"); printf("Sisestage K-kaardi NELJAS rida \n");
scanf("%s", d); scanf("%s", d);
}while(kontroll(d) == 1); }while(kontroll(d) == 1);
printf("\nTerviklik kaart:\n"); printf("\nTerviklik kaart:\n");
printf("\n%s\n", a); printf("\n%s\n", a);
printf("%s\n", b); printf("%s\n", b);
...@@ -239,7 +224,6 @@ int main(void){ ...@@ -239,7 +224,6 @@ int main(void){
char a[16], b[16], c[16], d[16]; char a[16], b[16], c[16], d[16];
int input; int input;
input = sisestus("Sisestage 4x4 Karnaugh kaart voi 16 loogikavaartust: \n", a, b, c, d); input = sisestus("Sisestage 4x4 Karnaugh kaart voi 16 loogikavaartust: \n", a, b, c, d);
kontroll(a);
if (input == 1){ if (input == 1){
return 1; return 1;
} }
...@@ -248,3 +232,4 @@ int main(void){ ...@@ -248,3 +232,4 @@ int main(void){
return 0; 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