Guest User

structponazvaniutovara

a guest
Feb 24th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <iostream.h>
  4. struct PRICE
  5. {
  6. char tovar[255];
  7. char shop[255];
  8. int cena;
  9. };
  10. int main()
  11. {
  12. const int n=2;
  13. PRICE a[n],buf;
  14. char product[255];
  15. int i,j,flag=0;
  16. i=0;
  17. while(i<2)
  18. {
  19. cin.ignore();
  20. printf("Vvedy nazvanie tovara\n");
  21. gets(a[i].tovar);
  22. printf("Vvedy Nazvanie magazina\n");
  23. gets(a[i].shop);
  24. printf("Vvedy Ceny tovara\n");
  25. scanf("%d",&a[i].cena);
  26. i++;
  27. }
  28. for (i=0;i<n-1;i++)
  29. for (j=n-2;j>=i;j--)
  30. if (strcmp(a[j].tovar,a[j+1].tovar)==1)
  31. {
  32. buf = a[j];
  33. a[j]= a[j+1];
  34. a[j+1] = buf;
  35. }
  36. printf("vvedite tovar dl9 opisani9 \n");
  37. scanf ("%s",product);
  38. printf("\tNAZVANIE MAGAZINA\tNAZVANIE TOVARA\t\tCENA\n");
  39. for (i=0;i<n;i++)
  40. {
  41. printf("%25s",a[i].shop);
  42. printf("%20s",a[i].tovar);
  43. printf("%15d\n",a[i].cena);
  44. }
  45. printf("Svedenie o tovare\n");
  46. for(i=0;i<n;i++)
  47. if (strcmp(a[i].tovar,product)==0)
  48. {
  49. printf("%45s",a[i].shop);
  50. printf("%15d\n",a[i].cena);
  51. flag=1;
  52. }
  53. if(flag==0)
  54. printf("Net takogo tovara !!\n");
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment