Puzzle:
A certain street has 1000 buildings. A sign-maker is contracted to number the houses from 1 to 1000. How many zeroes will he need?
Answer:
The sign-maker will need 192 zeroes.
Divide 1000 building numbers into groups of 100 each as follow:
(1..100), (101..200), (201..300), ....... (901..1000)
For the first group, sign-maker will need 11 zeroes.
For group numbers 2 to 9, he will require 20 zeroes each.
And for group number 10, he will require 21 zeroes.
The total numbers of zeroes required are
= 11 + 8*20 + 21
= 11 + 160 + 21
= 192
Consider the following example:
class B { ... };
class D : public B { ... };
void f()
{
B* pb = new D; // unclear but ok
B* pb2 = new B;
D* pd = dynamic_cast...
No comments:
Post a Comment