Page 3 of 3

Posted: Sun Dec 31, 2006 7:57 am
by Eva Tsai

Code: Select all



what the problem ?

Posted: Tue Jul 03, 2007 3:53 pm
by rezinha85
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));
}

Re: 11056 - Formula 1

Posted: Mon Jan 21, 2013 9:28 pm
by brianfry713
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


Re: 11056 - Formula 1

Posted: Wed Nov 13, 2013 1:21 am
by brianfry713
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


Re: 11056 - Formula 1

Posted: Wed Apr 02, 2014 2:09 pm
by uDebug
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