|
|
back to boardWA(7) Anyone help me? Posted by chenll 6 Mar 2006 17:22 I got WA on test 7. Is there some tricks on it? There are % operations in this test. Check if you calculate it correctly (-) Re: There are % operations in this test. Check if you calculate it correctly (-) Posted by chenll 6 Mar 2006 18:46 int modFunction(int a,int b) { int c=a%b; b=(b<0)?(-b):b; if(c<0) return c+b; return c; } is this correct? I used the following construction (+) func Mod(a,b: int): int; var Res: int; { Res:=a%b; if Res<0 then Res:=Res+abs(b); return Res; } Re: I used the following construction (+) Posted by chenll 6 Mar 2006 19:00 i think we are the same. So your mistake is somewhere else. Good luck (-) |
|
|