87 lines
1.8 KiB
C
87 lines
1.8 KiB
C
#include <stdio.h>
|
|
#include <ctype.h>
|
|
#include <stdbool.h>
|
|
#include <string.h>
|
|
//
|
|
bool check(char* s2, char *pz)
|
|
{
|
|
char s[300], p[300];
|
|
if(s2==NULL || pz==NULL)
|
|
{
|
|
return false;
|
|
}
|
|
// char *s=(char*) malloc(strlen(s2)+1);
|
|
// if(s==NULL)
|
|
// {
|
|
// return false;
|
|
// }
|
|
// 0123456789
|
|
char shifer[15]="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;
|
|
|
|
for(int i = 0; pz[i]!='\0'; i++)
|
|
{
|
|
//printf("%d ",i);
|
|
p[i] = tolower(pz[i]);
|
|
if(p[i] >='0' && p[i]<='9')
|
|
{
|
|
p[i]=shifer[p[i]-'0'];
|
|
}
|
|
}
|
|
p[strlen(pz)]=0;
|
|
|
|
//printf("========= %s %s %s", s2,pz,)
|
|
bool rez=strstr(s, p)!=NULL;
|
|
//free(s);
|
|
return rez;
|
|
|
|
}
|
|
|
|
int main()
|
|
{
|
|
char r[300];//="8ryNd20va P1zza";
|
|
char pizz[50];//="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("Nacitanych %d poloziek.\n", count);
|
|
|
|
return 0;
|
|
} |