From e588fa5727b79dd313628786050fa76711a84c8c Mon Sep 17 00:00:00 2001 From: Yurii Yakovenko Date: Mon, 30 Sep 2024 20:08:14 +0000 Subject: [PATCH] Update cv1/program.c --- cv1/program.c | 98 ++++++++++++++++++++++----------------------------- 1 file changed, 43 insertions(+), 55 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 544e001..db68c0f 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -1,70 +1,58 @@ #include #include - -// i -void change(char* s) /// " ksdjfghkh \0" +#include +// +bool check(char* s2, char *pz) { + char *s=(char*) malloc(strlen(s2)+1); char shifer[85]="oizeasbtbq"; - // 012 - for(int i = 0; s[i]!='\0'; i++) - // умова виконання + + for(int i = 0; s2[i]!='\0'; i++) + { - //printf("%d ",i); - s[i]=tolower(s[i]); + //printf("%d ",i); + s[i]=tolower(s2[i]); if(s[i] >='0' && s[i]<='9') - { // '0'=>текс - - printf("\n%c ",s[i]); + { + s[i]=shifer[s[i]-'0']; - printf("\n%c > ",s[i]); + } + } + bool rez=strstr(s, pz)!=NULL; + free(s2); + return rez; - } - } } - -// char x=69; // 'E => 'e' - -// . -// ABCDEFGH -// 01234 - -// if (s[i]== 'A') s[i]= 'a'; - -// x-'A' + 'a' 'R' => 'r' -// 65 97 -// s[i]=shifer[s[i]-'0'] - -// i => s[i] => -// 5 '2' z - -// 6 => s[6]='0' => 0 => shifr[0] => o -// 0 => s[0]='8' => 8 => shifr[8] => b -// 11 => s[11]='1' => 1 => shifr[1] => i - -// i -//nazva s: 8ryNd20va P1zza -// 0123456789011 - int main() -{ // - // char shifer[85]="oizeasbtbq"; - char r[99]="8ryNd20va P1zza"; - char br[99]; +{ + + char r[300];//="8ryNd20va P1zza"; + char pizz[99];//="piz"; + char *p; + float price; + int count =0; + scanf("%s", pizz); - scanf("%s", br); //jabl - - // do -// { - // punk cena; - // change(punkt); - // } - - printf("\n%s", r); - change(r); - printf("\n%s", r); + while(1) + { + do + p=fgets(r, 299, stdin); + while(p!=NULL && p[0]=='\n'); + if(p==NULL) + break; + //else printf("\n============ %s",r); + if(scanf("%f", &price)!=1) + break; + //else printf("%f",price); + if(check(r, pizz)) + { + count++; + printf("%s %.2f\n", r, price); + } + } + printf("Nacitanyh %d poloziek", count); + return 0; } - -