SHOW:
|
|
- or go back to the newest paste.
| 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 | i=0; | |
| 18 | while(i<2) | |
| 19 | //for(i=0;i<n;i++) | |
| 20 | {
| |
| 21 | cin.ignore(); | |
| 22 | printf("Vvedy nazvanie producta\n");
| |
| 23 | gets(a[i].product); | |
| 24 | // cin >> a[i].product; | |
| 25 | // cin.get(); | |
| 26 | printf("Vvedy Nazvanie magazina\n");
| |
| 27 | gets(a[i].shop); | |
| 28 | // cin >> a[i].shop; | |
| 29 | //cin.get(); | |
| 30 | printf("Vvedy Ceny producta\n");
| |
| 31 | scanf("%d",&a[i].value);
| |
| 32 | ||
| 33 | i++; | |
| 34 | } | |
| 35 | for (i=0;i<n-1;i++) | |
| 36 | - | scanf("%s",magaz);
|
| 36 | + | |
| 37 | - | printf("\tNAZVANIE MAGAZINA\tNAZVANIE TOVARA\tCENA\n");
|
| 37 | + | |
| 38 | {
| |
| 39 | buf = a[j]; | |
| 40 | a[j]= a[j+1]; | |
| 41 | a[j+1] = buf; | |
| 42 | } | |
| 43 | printf("vvedite magazin dl9 opisani9 \n");
| |
| 44 | - | printf("%15s",a[i].shop);
|
| 44 | + | scanf ("%s",magaz);
|
| 45 | - | printf("%15s",a[i].product);
|
| 45 | + | printf("\tNAZVANIE MAGAZINA\tNAZVANIE TOVARA\t\tCENA\n");
|
| 46 | for (i=0;i<n;i++) | |
| 47 | {
| |
| 48 | // cout«"\t"«a[i].shop; | |
| 49 | // cout«"\t\t\t"«a[i].product; | |
| 50 | // cout«"\t\t\t"«a[i].value; | |
| 51 | // cout«"\n"; | |
| 52 | printf("%25s",a[i].shop);
| |
| 53 | printf("%20s",a[i].product);
| |
| 54 | printf("%15d\n",a[i].value);
| |
| 55 | - | printf("%30s",a[i].product);
|
| 55 | + | |
| 56 | printf("Svedenie o magazine\n");
| |
| 57 | for(i=0;i<n;i++) | |
| 58 | if (strcmp(a[i].shop,magaz)==0) | |
| 59 | {
| |
| 60 | // cout«"\t\t\t\t"«a[i].product; | |
| 61 | // cout«"\t\t"«a[i].value; | |
| 62 | // cout«"\n"; | |
| 63 | printf("%45s",a[i].product);
| |
| 64 | printf("%15d\n",a[i].value);
| |
| 65 | flag=1; | |
| 66 | } | |
| 67 | if(flag==0) | |
| 68 | printf("Net takogo magazina !!\n");
| |
| 69 | return 0; | |
| 70 | } |