Guest User

Насте моя лажа

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