Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Quick

Name: Anonymous 2011-08-14 13:53


int digitCheck(int i, int j)
{
    while(i > 1)
    {
        --i;
        j /= 10;
        if (j < 1)
            return 1;
    }
   
    return 0;
}


It's supposedly ANSI C.

Just testing a compiler.

When should this return 0?
When should this return 1?

Name: TRUE TRUTH EXPERT 2011-08-14 14:04

/=

Name: Anonymous 2011-08-14 14:04

Never mind guys. Found the culprit!






HAX DEIN ASUS!ANUS!







Name: TRUE TRUTH EXPERT 2011-08-14 14:07

>>2
oOPS THAT'S REALLY THE DIVISION OPERATOR! sILLY ME!!!!!!!!!!!!
rETURNS 1 IF I > 1 AND J IS < 0 OR IF I > K WHERE 10K - 1 <= j < 10K

Name: Anonymous 2011-08-14 14:08

This should return 1, when j has at most i digits in base 10 and 0 otherwise.

So, for instance digitCheck(3, 123)=1 and digitCheck(2,123)=0.

Name: TRUE TRUTH EXPERT 2011-08-14 14:14

So, for instance digitCheck(3, 123)=1
nO IT WON'T!

Name: Anonymous 2011-08-14 14:20

>>6

Oh, well I guess off by one is also wrong.


It's log10(j) < i

So, digitCheck(3,99)=1 and digitCheck(3,100) is false.

Don't change these.
Name: Email:
Entire Thread Thread List