SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <stdio.h> | |
| 2 | #include <string.h> | |
| 3 | - | #include "iostream.h" |
| 3 | + | #include <iostream.h> |
| 4 | - | struct price |
| 4 | + | struct PRICE |
| 5 | {
| |
| 6 | - | char product[255]; |
| 6 | + | char tovar[255]; |
| 7 | - | char shop[255]; |
| 7 | + | char shop[255]; |
| 8 | - | int value; |
| 8 | + | int cena; |
| 9 | }; | |
| 10 | int main() | |
| 11 | {
| |
| 12 | - | const int n=2; |
| 12 | + | const int n=2; |
| 13 | - | price a[n],buf,magazin[255]; |
| 13 | + | PRICE a[n],buf; |
| 14 | - | char magaz[255]; |
| 14 | + | char product[255]; |
| 15 | - | int i,j,flag=0; |
| 15 | + | int i,j,flag=0; |
| 16 | - | printf("Hello\n");
|
| 16 | + | i=0; |
| 17 | - | i=0; |
| 17 | + | while(i<2) |
| 18 | - | while(i<2) |
| 18 | + | {
|
| 19 | - | //for(i=0;i<n;i++) |
| 19 | + | cin.ignore(); |
| 20 | - | {
|
| 20 | + | printf("Vvedy nazvanie tovara\n");
|
| 21 | - | cin.ignore(); |
| 21 | + | gets(a[i].tovar); |
| 22 | - | printf("Vvedy nazvanie producta\n");
|
| 22 | + | printf("Vvedy Nazvanie magazina\n");
|
| 23 | - | gets(a[i].product); |
| 23 | + | gets(a[i].shop); |
| 24 | - | // cin >> a[i].product; |
| 24 | + | printf("Vvedy Ceny tovara\n");
|
| 25 | - | // cin.get(); |
| 25 | + | scanf("%d",&a[i].cena);
|
| 26 | - | printf("Vvedy Nazvanie magazina\n");
|
| 26 | + | i++; |
| 27 | - | gets(a[i].shop); |
| 27 | + | } |
| 28 | - | // cin >> a[i].shop; |
| 28 | + | for (i=0;i<n-1;i++) |
| 29 | - | //cin.get(); |
| 29 | + | for (j=n-2;j>=i;j--) |
| 30 | - | printf("Vvedy Ceny producta\n");
|
| 30 | + | if (strcmp(a[j].tovar,a[j+1].tovar)==1) |
| 31 | - | scanf("%d",&a[i].value);
|
| 31 | + | {
|
| 32 | - | |
| 32 | + | buf = a[j]; |
| 33 | - | i++; |
| 33 | + | a[j]= a[j+1]; |
| 34 | - | } |
| 34 | + | a[j+1] = buf; |
| 35 | - | for (i=0;i<n-1;i++) |
| 35 | + | } |
| 36 | - | for (j=n-2;j>=i;j--) |
| 36 | + | printf("vvedite tovar dl9 opisani9 \n");
|
| 37 | - | if (strcmp(a[j].shop,a[j+1].shop)==1) |
| 37 | + | scanf ("%s",product);
|
| 38 | - | {
|
| 38 | + | printf("\tNAZVANIE MAGAZINA\tNAZVANIE TOVARA\t\tCENA\n");
|
| 39 | - | buf = a[j]; |
| 39 | + | for (i=0;i<n;i++) |
| 40 | - | a[j]= a[j+1]; |
| 40 | + | {
|
| 41 | - | a[j+1] = buf; |
| 41 | + | printf("%25s",a[i].shop);
|
| 42 | - | } |
| 42 | + | printf("%20s",a[i].tovar);
|
| 43 | - | printf("vvedite magazin dl9 opisani9 \n");
|
| 43 | + | printf("%15d\n",a[i].cena);
|
| 44 | - | scanf ("%s",magaz);
|
| 44 | + | } |
| 45 | - | printf("\tNAZVANIE MAGAZINA\tNAZVANIE TOVARA\t\tCENA\n");
|
| 45 | + | printf("Svedenie o tovare\n");
|
| 46 | - | for (i=0;i<n;i++) |
| 46 | + | for(i=0;i<n;i++) |
| 47 | - | {
|
| 47 | + | if (strcmp(a[i].tovar,product)==0) |
| 48 | - | // cout«"\t"«a[i].shop; |
| 48 | + | {
|
| 49 | - | // cout«"\t\t\t"«a[i].product; |
| 49 | + | printf("%45s",a[i].shop);
|
| 50 | - | // cout«"\t\t\t"«a[i].value; |
| 50 | + | printf("%15d\n",a[i].cena);
|
| 51 | - | // cout«"\n"; |
| 51 | + | flag=1; |
| 52 | - | printf("%25s",a[i].shop);
|
| 52 | + | } |
| 53 | - | printf("%20s",a[i].product);
|
| 53 | + | if(flag==0) |
| 54 | - | printf("%15d\n",a[i].value);
|
| 54 | + | printf("Net takogo tovara !!\n");
|
| 55 | - | } |
| 55 | + | return 0; |
| 56 | - | printf("Svedenie o magazine\n");
|
| 56 | + |