74 lines
1.4 KiB
C
74 lines
1.4 KiB
C
#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("Nacitanych %d poloziek", count);
|
|
|
|
return 0;
|
|
} |