Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- typedef struct {
- char name[10];
- char address[50];
- int day;
- int month;
- int year;
- } Delivery;
- void input(Delivery *P);
- void output(Delivery *P);
- int main()
- {
- Delivery mass[6], *P, max;
- P = mass;
- int k, i, j;
- for (k=0; k<5; k++)
- {
- printf("%d Address:\n", k+1);
- input(P);
- P++;
- }
- for(i=0; i<5; i++)
- {
- for(j=0; j<5; j++)
- {
- max = mass[j];
- if(mass[j+1].year < max.year)
- {
- mass[j]=mass[j+1];
- mass[j+1]=max;
- if(mass[j+1].month < max.month)
- {
- mass[j]=mass[j+1];
- mass[j+1]=max;
- }
- if(mass[j+1].day < max.day)
- {
- mass[j]=mass[j+1];
- mass[j+1]=max;
- }
- }
- }
- }
- P = mass;
- for(j=0; j<5; j++)
- {
- output(P);
- P++;
- }
- return 0;
- }
- void input(Delivery *P){
- printf("Enter the reciver's name: ");
- scanf("%s", P->name);
- printf("Enter the reciver's address: ");
- scanf("%s", P->address);
- do
- {
- printf("Enter the delivery day: ");
- scanf("%d", &P->day);
- }
- while ((P->day < 0) ||(P->day > 31));
- do
- {
- printf("Enter the delivery month: ");
- scanf("%d", &P->month);
- }
- while (P->month < 0 || P->month > 12);
- do
- {
- printf("Enter the delivery year: ");
- scanf("%d", &P->year);
- }
- while (P->year < 0);
- printf("\n");
- }
- void output(Delivery *P){
- printf("%s %s %d %d %d\n", P->name, P->address, P->day, P->month, P->year);
- }
Add Comment
Please, Sign In to add comment