Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <conio.h>
- #include <stdlib.h>
- int main(void)
- {
- struct date
- {
- int d, m, y;
- };
- struct medt {
- char name[64];
- struct date release;
- int count, term;
- float price;
- } *medts;
- struct date now;
- int n, i, j;
- float overTermPrice = 0.0;
- printf("input n: "); scanf("%d", &n);
- printf("input date (dd mm yyyy):"); scanf("%d %d %d", &now.d, &now.m, &now.y);
- medts = (struct medt*)malloc(sizeof(*medts) * n);
- fflush(stdin);
- for (i = 0; i < n; i++)
- {
- printf("Input name: "); gets(medts[i].name);
- printf("Input price count: "); scanf("%f %d", &medts[i].price, &medts[i].count);
- printf("input term (years): "); scanf("%d", &medts[i].term);
- printf("input release date (dd mm yyyy): "); scanf("%d %d %d", &medts[i].release.d, &medts[i].release.m, &medts[i].release.y);
- fflush(stdin);
- }
- for (i = 0; i < n; i++)
- {
- if (medts[i].release.y + medts[i].term - now.y < 0)
- overTermPrice += medts[i].price * medts[i].count;
- else if (medts[i].release.y + medts[i].term - now.y == 0)
- if (medts[i].release.m - now.m < 0)
- overTermPrice += medts[i].price * medts[i].count;
- else if (medts[i].release.m - now.m == 0)
- if (medts[i].release.d - now.d < 0)
- overTermPrice += medts[i].price * medts[i].count;
- }
- printf("Sum = %f", overTermPrice);
- free(medts);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment