This is a mirror of official site: http://jasper-net.blogspot.com/

C++ Coding Challenge #1

| Sunday, December 19, 2010
Problem: Write a program that will find the largest element of an arbitrary array without using any conditional structures: banned { if/if-else/switch/for/while/do/?:-operator }

bonus: Display the array sorted from smallest to largest with the same conditions.

i.e. write the function max in this little program:

int main() {
   int array[] = { 3, 1, 4, 15, 9, 2, 6, 5, 35, 8, 97, 93, 23, 84, 62, 64, 33, 83, 27, 950, 28, 841, 971, 69, 39, 937, 510 };
   cout << "Largest element is: " << max(array) << endl;
   return 0;
}

Read more: <dream-in-code>

Posted via email from .NET Info

0 comments: