sergFBI
Newbie | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору #include <stdio.h> #include <string.h> #include <math.h> #include <conio.h> #include <stdlib.h> typedef struct B{ int tot; char denum[20]; char sos[100];}T; typedef struct D{ char fel[50];}TT; int main () {T tab[20]; TT tabb[50]; int zz=0; int N[50]; int c1, c2, c3, i, j, l, k, m, n, t, temp, s1, s2, s3, w, q; char y[30], R[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); } char *pch; for (i=0;i<w;i++) { pch = strtok (tab[i].sos," ,.-"); while (pch != NULL) { for (k=0;k<50;k++) { // escli znacenie "PCH" esti v structure to +1 k ego znaceniu v masive N if (strcmp(pch,tabb[k].fel)==0) {N[k]++;} } for (m=0;m<50;m++) { // provereaem na nalicie v structure zapisi v "PCH" ! if (strcmp(pch,tabb[m].fel)!=0) {n=1;} if (strcmp(pch,tabb[m].fel)==0) {n=0;} } // esli v strukture netu Sostavnogo producta [n=1] togda vnosim znacenie v structuru if (n == 1) {strcpy(tabb[zz].fel,pch); N[zz]++; n=0; zz++;} pch = strtok (NULL, " ,.-"); } } for(i=0;i<zz-1;i++){y[i]=N[i];} //Searcing for max for(i=0;i<zz-1;i++){ for(j=i+1;j<zz-1;j++){ if (y[i]<y[j]){temp = y[i]; y[i] = y[j]; y[j]= temp;} } } temp=y[0]; // vivod na ecran Sostavnogo producta s nai bolishim znaceniem v masive for(i=0;i<zz-1;i++){ if (temp == N[i]) {printf("Most used is %s \n",tabb[i].fel);} } getch(); } | Всего записей: 25 | Зарегистр. 23-04-2008 | Отправлено: 14:06 04-05-2008 | Исправлено: sergFBI, 14:08 04-05-2008 |
|