FunctionTroubleProblem code: PGM3 |
All submissions for this problem are available.
Write the comparison function qs_compare()for the following code:
struct date
{
int d,m,y;
};
qs_compare(const void*,const void*);
struct date dd[1000];
void main()
{
int i,w,n;
w=sizeof(struct date);
//Read the inputs
qsort(dd,n,w,qs_compare);//n is the number of dates
//Print the result
}
Input
5 17 11 62 24 8 78 17 11 62 16 12 76 19 2 94Output
17-11-1962 17-11-1962 16-12-1976 24-8-1978 19-2-1994
| Date: | 2010-02-26 |
| Time limit: | 3s |
| Source limit: | 50000 |
| Languages: | C |
Comments

Fetching successful submissions

struct date{int
struct date
{
int d,m,y;
};
qs_compare(const void*,const void*);
struct date dd[1000];
void main()
{
int i,w,n;
w=sizeof(struct date);
printf("n enter the size");
scanf("%d",&n);
printf("n entre the nors");
for(i=0;i<n;i++)
{
printf(:"n enter the daten");
scanf("%d",&dd[i].d;
printf("n enter the monthn");
scanf("%d",&dd[i].m;
printf("n enter the yearn");
scanf("%d",&dd[i].y;
}
qsort(dd,n,w,qs_compare);//n is the number of dates
pintf("n sorted date");
for(i=0;i< n;i++)
{
printf("n %d-%d-%d",dd[i].d,dd[i].m,dd[i].y);
}
}
void qsort(struct structdate dd,int n,structdate p*,