usaa24/cv1/program.c

69 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:08:14 +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-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
}
}
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
{
char r[300];//="8ryNd20va P1zza";
char pizz[99];//="piz";
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);
while(1)
{
2024-09-30 20:20:35 +00:00
printf("Zadaj␣jedalny␣listok:\n");
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:07:16 +00:00
}
2024-10-01 14:12:29 +00:00
while(p!=NULL && p[0]=='\n');
2024-09-30 20:08:14 +00:00
{
2024-10-01 19:07:16 +00:00
if(p==NULL)
{
break;
}
if(scanf("%f", &price)!=1)
{
break;
}
if(check(r, pizz))
{
count++;
printf("%s %.2f\n", r, price);
}
}
2024-09-30 20:08:14 +00:00
}
printf("Nacitanyh %d poloziek", count);
2024-09-30 13:22:26 +00:00
return 0;
2024-10-01 19:07:16 +00:00
}