Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <locale.h>
- #include <conio.h>
- #include <string.h>
- struct instrument
- {
- char name[20];
- float price;
- int grt_period_day;
- };
- struct zamov
- {
- char name[40];
- char adress[40];
- int kolvo;
- };
- struct measurement
- {
- int array[20];
- char veli[15];
- float top[20];
- float lower[20];
- float delta[20];
- };
- int main()
- {
- int a=20,j,i;
- int k=0;
- struct instrument inst[a];
- struct zamov zm[a];
- struct measurement mst[a];
- setlocale(LC_ALL,"rus");
- FILE *input=NULL;
- do
- {
- k=0;
- printf("Кол-во инструментов: ");
- scanf("%d",&a);
- if(a<1)
- {
- printf("Минимальное значения для данного параметра - 1\n");
- k=1;
- }
- }
- while(k!=0);
- for(i=0;i<a;i++)
- {
- printf("Название: ");
- scanf("%s",inst[i].name);
- //gets(inst[i].name);
- do
- {
- k=0;
- printf("Цена: ");
- scanf("%f",&inst[i].price);
- if(inst[i].price<10)
- {
- printf("Введите цену побольше!\n");
- k=1;
- }
- }
- while(k!=0);
- do
- {
- k=0;
- printf("Гарантичный срок (дней): ");
- scanf("%d",&inst[i].grt_period_day);
- if(inst[i].grt_period_day<29)
- {
- printf("Гарантийный строк должен быть не менее 30 дней!\n");
- k=1;
- }
- }
- while(k!=0);
- printf("ФИО заказчика: ");
- scanf("%s",zm[i].name);
- printf("Адрес: ");
- scanf("%s",zm[i].adress);
- do
- {
- printf("Колво товаров: ");
- k=0;
- scanf("%d",&zm[i].kolvo);
- }
- while(k!=0);
- do
- {
- k=0;
- printf("Сколько велечин измеряет инструмент?\n@: ");
- scanf("%d",&mst[i].array[i]);
- if(mst[i].array[i]<1)
- {
- printf("Минимальное значения для данного параметра - 1\n");
- k=1;
- }
- }
- while(k!=0);
- for(j=0;j<mst[i].array[i];j++)
- {
- printf("Велечина: ");
- scanf("%s",&mst[i].veli[j]);
- printf("Нижняя грань: ");
- scanf("%f",&mst[i].lower[j]);
- do
- {
- k=0;
- printf("Верхняя грань: ");
- scanf("%f",&mst[i].top[j]);
- if(mst[i].top[j]<mst[i].lower[j]+10)
- {
- printf("Введите значения побольше!\n");
- k=1;
- }
- }
- while(k!=0);
- do
- {
- k=0;
- printf("Погрешность: ");
- scanf("%f",&mst[i].delta[j]);
- if(mst[i].delta[j]<0)
- {
- printf("Погрешность не может быть ниже 0\n");
- k=1;
- }
- }
- while(k!=0);
- puts(" ");
- }
- }
- input=fopen("1input","wb");
- if (input == NULL)
- {
- printf("Ошибка при открытии файла");
- return 0;
- }
- fwrite(&inst, sizeof(struct instrument), a, input);
- fclose(input);
- input = fopen("1input", "rb");
- if (input == NULL)
- {
- printf("Ошибка при открытии файла");
- return 0;
- }
- fread(&inst, sizeof(struct instrument), a, input);
- input=fopen("2input","wb");
- if (input == NULL)
- {
- printf("Ошибка при открытии файла");
- return 0;
- }
- fwrite(&inst, sizeof(struct zamov), a, input);
- fclose(input);
- input = fopen("2input", "rb");
- if (input == NULL)
- {
- printf("Ошибка при открытии файла");
- return 0;
- }
- fread(&inst, sizeof(struct zamov), a, input);
- input=fopen("3input","wb");
- if (input == NULL)
- {
- printf("Ошибка при открытии файла");
- return 0;
- }
- fwrite(&inst, sizeof(struct measurement), a, input);
- fclose(input);
- input = fopen("3input", "rb");
- if (input == NULL)
- {
- printf("Ошибка при открытии файла");
- return 0;
- }
- fread(&inst, sizeof(struct measurement), a, input);
- float delt;
- do
- {
- k=0;
- printf("Погрешность: ");
- scanf("%f",&delt);
- if(delt<0)
- {
- printf("Введите значения побольше!\n");
- k=1;
- }
- }
- while(k!=0);
- int h=1;
- for(i=0;i<a;i++)
- {
- k=0;
- for(j=0;j<mst[i].array[i];j++)
- {
- if(delt>=mst[i].delta[j])
- {
- if(k==0)
- {
- printf("\n%d) %s\n",h,zm[i].name);
- h++;
- k=1;
- }
- }
- }
- }
- fclose(input);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement