From 570d9ec0392f65231d24252d3cca354b392d9d32 Mon Sep 17 00:00:00 2001 From: Yurii Yakovenko Date: Tue, 1 Oct 2024 19:07:16 +0000 Subject: [PATCH] Update cv1/program.c --- cv1/program.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 914a534..15e98b3 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -5,6 +5,10 @@ bool check(char* s2, char *pz) { char *s=(char*) malloc(strlen(s2)+1); + if(s==NULL) + { + return false; + } char shifer[85]="oizeasbtbq"; for(int i = 0; s2[i]!='\0'; i++) @@ -38,19 +42,28 @@ int main() { printf("Zadaj␣jedalny␣listok:\n"); do - p=fgets(r, 299, stdin); - while(p!=NULL && p[0]=='\n'); - if(p==NULL) - break; - if(scanf("%f", &price)!=1) - break; - if(check(r, pizz)) { - count++; - printf("%s %.2f\n", r, price); - } + p=fgets(r, 299, stdin); + } + + while(p!=NULL && p[0]=='\n'); + { + if(p==NULL) + { + break; + } + if(scanf("%f", &price)!=1) + { + break; + } + if(check(r, pizz)) + { + count++; + printf("%s %.2f\n", r, price); + } + } } printf("Nacitanyh %d poloziek", count); return 0; -} +} \ No newline at end of file