Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <iostream.h>
- struct PRICE
- {
- char tovar[255];
- char shop[255];
- int cena;
- };
- int main()
- {
- const int n=2;
- PRICE a[n],buf;
- char product[255];
- int i,j,flag=0;
- i=0;
- while(i<2)
- {
- cin.ignore();
- printf("Vvedy nazvanie tovara\n");
- gets(a[i].tovar);
- printf("Vvedy Nazvanie magazina\n");
- gets(a[i].shop);
- printf("Vvedy Ceny tovara\n");
- scanf("%d",&a[i].cena);
- i++;
- }
- for (i=0;i<n-1;i++)
- for (j=n-2;j>=i;j--)
- if (strcmp(a[j].tovar,a[j+1].tovar)==1)
- {
- buf = a[j];
- a[j]= a[j+1];
- a[j+1] = buf;
- }
- printf("vvedite tovar dl9 opisani9 \n");
- scanf ("%s",product);
- printf("\tNAZVANIE MAGAZINA\tNAZVANIE TOVARA\t\tCENA\n");
- for (i=0;i<n;i++)
- {
- printf("%25s",a[i].shop);
- printf("%20s",a[i].tovar);
- printf("%15d\n",a[i].cena);
- }
- printf("Svedenie o tovare\n");
- for(i=0;i<n;i++)
- if (strcmp(a[i].tovar,product)==0)
- {
- printf("%45s",a[i].shop);
- printf("%15d\n",a[i].cena);
- flag=1;
- }
- if(flag==0)
- printf("Net takogo tovara !!\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment