usaa24/cv1/program.c

69 lines
1.4 KiB
C

#include <stdio.h>
#include <ctype.h>
#include <stdbool.h>
// /
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++)
{
//printf("%d ",i);
s[i]=tolower(s2[i]);
if(s[i] >='0' && s[i]<='9')
{
s[i]=shifer[s[i]-'0'];
}
}
bool rez=strstr(s, pz)!=NULL;
free(s);
return rez;
}
int main()
{
char r[300];//="8ryNd20va P1zza";
char pizz[99];//="piz";
char *p;
float price;
int count =0;
printf("Zadaj hladanu surovinu:\n");
scanf("%s", pizz);
while(1)
{
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);
}
}
}
printf("Nacitanyh %d poloziek", count);
return 0;
}