2024-09-30 13:22:26 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
2024-09-30 20:08:14 +00:00
|
|
|
#include <stdbool.h>
|
2024-10-01 20:15:33 +00:00
|
|
|
#include <string.h>
|
2024-10-01 19:13:33 +00:00
|
|
|
//
|
2024-09-30 20:08:14 +00:00
|
|
|
bool check(char* s2, char *pz)
|
2024-10-01 20:18:58 +00:00
|
|
|
{
|
2024-10-02 19:29:16 +00:00
|
|
|
char s[300], p[300];
|
2024-10-01 19:13:33 +00:00
|
|
|
if(s2==NULL || pz==NULL)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2024-10-01 20:18:58 +00:00
|
|
|
// char *s=(char*) malloc(strlen(s2)+1);
|
|
|
|
// if(s==NULL)
|
|
|
|
// {
|
|
|
|
// return false;
|
|
|
|
// }
|
2024-10-02 19:29:16 +00:00
|
|
|
// 0123456789
|
2024-10-01 20:15:33 +00:00
|
|
|
char shifer[15]="oizeasbtbq";
|
2024-09-30 20:08:14 +00:00
|
|
|
|
2024-09-30 20:20:35 +00:00
|
|
|
for(int i = 0; s2[i]!='\0'; i++)
|
2024-09-30 13:22:26 +00:00
|
|
|
{
|
2024-09-30 20:08:14 +00:00
|
|
|
//printf("%d ",i);
|
|
|
|
s[i]=tolower(s2[i]);
|
2024-09-30 13:22:26 +00:00
|
|
|
if(s[i] >='0' && s[i]<='9')
|
2024-09-30 20:08:14 +00:00
|
|
|
{
|
|
|
|
|
2024-09-30 13:22:26 +00:00
|
|
|
s[i]=shifer[s[i]-'0'];
|
2024-09-30 20:08:14 +00:00
|
|
|
}
|
2024-10-01 19:14:47 +00:00
|
|
|
}
|
|
|
|
s[strlen(s2)]=0;
|
2024-10-02 19:29:16 +00:00
|
|
|
|
|
|
|
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;
|
2024-10-01 20:18:58 +00:00
|
|
|
//free(s);
|
2024-09-30 20:08:14 +00:00
|
|
|
return rez;
|
2024-09-30 13:22:26 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
2024-10-01 20:15:33 +00:00
|
|
|
{
|
|
|
|
char r[300];//="8ryNd20va P1zza";
|
|
|
|
char pizz[50];//="piz";
|
2024-09-30 20:08:14 +00:00
|
|
|
char *p;
|
|
|
|
float price;
|
|
|
|
int count =0;
|
2024-09-30 20:20:35 +00:00
|
|
|
printf("Zadaj hladanu surovinu:\n");
|
2024-09-30 20:08:14 +00:00
|
|
|
scanf("%s", pizz);
|
2024-10-01 19:27:56 +00:00
|
|
|
|
2024-10-02 08:16:32 +00:00
|
|
|
printf("Zadaj jedalny listok:\n");
|
2024-09-30 20:08:14 +00:00
|
|
|
while(1)
|
2024-10-01 20:15:33 +00:00
|
|
|
{
|
2024-09-30 20:08:14 +00:00
|
|
|
do
|
2024-10-01 19:07:16 +00:00
|
|
|
{
|
2024-09-30 20:08:14 +00:00
|
|
|
p=fgets(r, 299, stdin);
|
2024-10-01 19:27:56 +00:00
|
|
|
}while(p!=NULL && p[0]=='\n');
|
|
|
|
|
|
|
|
if(p==NULL)
|
|
|
|
{
|
|
|
|
break;
|
2024-10-01 19:07:16 +00:00
|
|
|
}
|
2024-10-01 19:36:52 +00:00
|
|
|
//printf("\n++%s", r);
|
2024-10-01 19:27:56 +00:00
|
|
|
if(scanf("%f", &price)!=1)
|
2024-09-30 20:08:14 +00:00
|
|
|
{
|
2024-10-01 19:07:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2024-10-01 19:27:56 +00:00
|
|
|
if(check(r, pizz))
|
2024-10-02 19:29:16 +00:00
|
|
|
{
|
2024-10-01 19:40:28 +00:00
|
|
|
printf("%s%.2f\n", r, price);
|
2024-10-01 19:27:56 +00:00
|
|
|
}
|
2024-10-01 19:36:52 +00:00
|
|
|
count++;
|
|
|
|
}
|
2024-10-01 19:57:42 +00:00
|
|
|
printf("Nacitanych %d poloziek.\n", count);
|
2024-09-30 20:08:14 +00:00
|
|
|
|
2024-09-30 13:22:26 +00:00
|
|
|
return 0;
|
2024-10-01 19:36:52 +00:00
|
|
|
}
|