At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your **free** account and access **expert** answers to this and **thousands** of other questions.

See more answers at brainly.com

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your **free** account and access **expert** answers to this and **thousands** of other questions

Can you define what you mean by interesting?

No :(

Ok then the most interesting algorithm I know is one that I wrote. ;)

Which one lol.

Yeah which one? lol

They are all interesting to me.

yes

when I was 12, I didn't even know what an algorithm was :-P

lol - neither did I.

so if I type in "42" it appends "nd" to the end?

hmm... let's try doing it in C!

Yes.

The trick is doing the check during your parse routine.

Yes.

i'm not too good with parsing though :(

I don't know enough C to help you there.

Yeah I figured. Seems that way with most languages that are direct derivatives of each other.

that appendix algorithm isn't so trivial in C :(

http://ideone.com/FIUgO so that's it in C++. Time to try it in C :-D

This is an interesting exercise in C :)

What you have looks about right. Does it work?

it seems to work

Yup.

So now see if you can do it without parsing.

Using int variables.

Should be able to do it with math. I'm trying to figure out the formula now.

lol

What's so funny. I wait. I know. I'm a geek. Tell me something I don't already know.

mod 10!

http://ideone.com/IuM5n there we go

Yeah that's what I was thinking.
If Number % 10 = 1 then sNumber = Number + "st"
and so forth.

Yep did you test?

I don't like '11st' or '12nd' or '13rd' though... how do we fix those cases?

Yes I believe i have a check in there for those numbers.

http://ideone.com/0enJt fixed

Yep. Exactly.

I think the C version is easy to do now :-D

See. Told you it was trivial. ;)

hmm.... but my code won't do it properly if you give it something like 111 or 112 or 113 :(

because you are only checking 11-13.

right.... how do I fix it?

Mod 100

but it will break if I give it a bigger number like 1111 or 1112 :-D

hmm. good point.

so in order for me to make it work for arbitrary numbers, I must use strings?

No shouldn't. I know this is calculable.

http://ideone.com/G1Ydb so the string version is now working correctly.

I shall ask this one in the Math section :-D I'm sure someone will answer it

I'm going to try to figure it out, but post your solution on ideone when you have it.

No I think mod 100 will work. Show me how it breaks.

http://ideone.com/lYxkE

you're right... it works!

112 mod 100 = 12
1112 mod 100 = 12
11112 mod 100 = 12
ad infinitum

Yea!

Who says you can't learn anything from trivial things?

This is why I believe there is no such thing as a 'stupid question'