#include <string.h> #include <stdio.h> #include <math.h> #include <conio.h> #include <stdlib.h> #define a "iabloko" #define p "persik" #define b "," typedef struct B{int tot; char denum[20]; char sos[100];}T; void main() {T tab[20]; int c1, c2, c3, i, j,l, m, t, temp, s1, s2, s3, w; char y[30], N[20], P[20]; clrscr(); printf("\n Asortiment => "); scanf("%d",&w); for(i=0; i<w; i++) { printf("\n 3) Imea producta => "); scanf("%s",&tab[i].denum); printf("\n 8) sostav soka => "); scanf("%s",&tab[i].sos); } printf("\n spisok sokov s soderjaniem iabloko i persik:"); char *pch; for (i=0;i<w;i++) { int q=0; pch = strtok (tab[i].sos," ,.-"); while (pch != NULL) { if (strcmp(pch,y)==0) q++; if (strcmp(pch,p)==0) q++; pch = strtok (NULL, " ,.-"); } if (q==2)printf("%s",tab[i].denum); // return 0; } /* char *token; for (i=0;i<w;i++) {int q=0; token=strtok(tab[i].sos,b) if (strcmp(token,y)==0) q++; if (strcmp(token,p)==0) q++; if (q==2)printf("%s",tab[i].denum) } */ getch(); } |