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 product[255];
- char shop[255];
- int value;
- };
- int main()
- {
- const int n=2;
- price a[n],buf,magazin[255];
- char magaz[255];
- int i,j,flag=0;
- printf("Hello\n");
- for(i=0;i<n;i++)
- {
- cin.ignore();
- printf("Vvedy nazvanie producta\n");
- gets(a[i].product);
- printf("Vvedy Nazvanie magazina\n");
- gets(a[i].shop);
- printf("Vvedy Ceny producta\n");
- scanf("%d",&a[i].value);
- }
- for (i=0;i<n-1;i++)
- for (j=n-2;j>=i;j--)
- if (strcmp(a[j].shop,a[j+1].shop)==1)
- {
- buf = a[j];
- a[j]= a[j+1];
- a[j+1] = buf;
- }
- printf("vvedite magazin dl9 opisani9 \n");
- scanf("%s",magaz);
- printf("\tNAZVANIE MAGAZINA\tNAZVANIE TOVARA\tCENA\n");
- for (i=0;i<n;i++)
- {
- // cout«"\t"«a[i].shop;
- // cout«"\t\t\t"«a[i].product;
- // cout«"\t\t\t"«a[i].value;
- // cout«"\n";
- printf("%15s",a[i].shop);
- printf("%15s",a[i].product);
- printf("%15d\n",a[i].value);
- }
- printf("Svedenie o magazine\n");
- for(i=0;i<n;i++)
- if (strcmp(a[i].shop,magaz)==0)
- {
- // cout«"\t\t\t\t"«a[i].product;
- // cout«"\t\t"«a[i].value;
- // cout«"\n";
- printf("%30s",a[i].product);
- printf("%15d\n",a[i].value);
- flag=1;
- }
- if(flag==0)
- printf("Net takogo magazina !!\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment