usaa24/cv1/program.c

74 lines
1.4 KiB
C
Raw Normal View History

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 19:13:33 +00:00
//
2024-09-30 20:08:14 +00:00
bool check(char* s2, char *pz)
2024-09-30 13:22:26 +00:00
{
2024-10-01 19:13:33 +00:00
if(s2==NULL || pz==NULL)
{
return false;
}
2024-09-30 20:08:14 +00:00
char *s=(char*) malloc(strlen(s2)+1);
2024-10-01 19:07:16 +00:00
if(s==NULL)
{
return false;
}
2024-09-30 13:22:26 +00:00
char shifer[85]="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-09-30 20:08:14 +00:00
bool rez=strstr(s, pz)!=NULL;
2024-09-30 20:25:34 +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-09-30 20:08:14 +00:00
{
2024-10-01 19:13:33 +00:00
char r[3000];//="8ryNd20va P1zza";
char pizz[990];//="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
printf("Zadaj␣jedalny␣listok:\n");
2024-09-30 20:08:14 +00:00
while(1)
{
2024-10-01 19:27:56 +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-01 19:35:49 +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:45:58 +00:00
printf("Nacitanych %d poloziek", 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
}