usaa24/cv1/program.c

74 lines
1.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
#include <ctype.h>
#include <stdbool.h>
//
bool check(char* s2, char *pz)
{
if(s2==NULL || pz==NULL)
{
return false;
}
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'];
}
}
s[strlen(s2)]=0;
bool rez=strstr(s, pz)!=NULL;
free(s);
return rez;
}
int main()
{
char r[3000];//="8ryNd20va P1zza";
char pizz[990];//="piz";
char *p;
float price;
int count =0;
printf("Zadaj hladanu surovinu:\n");
scanf("%s", pizz);
printf("Zadaj␣jedalny␣listok:\n");
while(1)
{
do
{
p=fgets(r, 299, stdin);
}while(p!=NULL && p[0]=='\n');
if(p==NULL)
{
break;
}
//printf("\n++%s", r);
if(scanf("%f", &price)!=1)
{
break;
}
if(check(r, pizz))
{
printf("%s%.2f\n", r, price);
}
count++;
}
printf("Nacitanyсh %d poloziek", count);
return 0;
}