## 11056 - Formula 1

All about problems in Volume 110. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Eva Tsai
New poster
Posts: 4
Joined: Sun Jul 10, 2005 11:01 am

Code: Select all

``````
``````
Last edited by Eva Tsai on Sat Jul 07, 2007 8:51 am, edited 1 time in total.

rezinha85
New poster
Posts: 1
Joined: Wed Jun 13, 2007 2:33 pm

### what the problem ?

what the problem in the function?

Code: Select all

``````int sorting_function(const void *a, const void *b)
{
racer *x = (racer *) a;
racer *y = (racer *) b;

if(x->minute != y->minute)
return x->minute - y->minute;
else if(x->second != y->second)
return x->second - y->second;
else if(x->msecond != y->msecond)
return x->msecond - y->msecond;
else
return (strcasecmp((char *) x->name, (char *) y->name));
}
``````

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 11056 - Formula 1

Input:

Code: Select all

``````3
Aa : 1 min 23 sec 172 ms
B : 1 min 23 sec 172 ms
ab : 1 min 23 sec 172 ms

3
aa : 1 min 23 sec 172 ms
b : 1 min 23 sec 172 ms
Ab : 1 min 23 sec 172 ms``````
AC output:

Code: Select all

``````Row 1
Aa
ab
Row 2
B

Row 1
aa
Ab
Row 2
b

``````
Check input and AC output for thousands of problems on uDebug!

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 11056 - Formula 1

Input:

Code: Select all

``````2
a : 1 min 23 sec 172 ms
bb : 1 min 23 sec 172 ms
``````
AC output:

Code: Select all

``````Row 1
a
bb

``````
Check input and AC output for thousands of problems on uDebug!

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

### Re: 11056 - Formula 1

Martin Macko wrote:strcasecmp() should work well enoung here. Alternatively, you can make lowercase copies of the strings a compare them.
Thank you. This really helped big time. Actually, I found the following discussion useful

http://www.cplusplus.com/forum/beginner/12089/

Especially what's shared by jsmith.

Next, I found the following input / output useful during testing / debugging.

Note that in the output there's a newline after every test case - even after the last one.

Input:

Code: Select all

``````4
a1 : 1 min 1 sec 1 ms
aa : 1 min 1 sec 1 ms
Aa : 1 min 1 sec 1 ms
aA : 1 min 1 sec 1 ms

7
a1 : 1 min 1 sec 1 ms
aa : 1 min 1 sec 1 ms
aaa : 0 min 1 sec 1 ms
aaa : 2 min 1 sec 1 ms
aaa : 2 min 1 sec 1 ms
aAa : 2 min 1 sec 1 ms
a1a : 2 min 1 sec 1 ms ``````
AC Output:

Code: Select all

``````Row 1
a1
aa
Row 2
Aa
aA

Row 1
aaa
a1
Row 2
aa
a1a
Row 3
aaa
aaa
Row 4
aAa

``````
Check input and AC output for over 7,500 problems on uDebug!