Advertisement

the non-geek curse

Started by September 03, 2002 05:53 PM
30 comments, last by Morpho84 22 years, 4 months ago

  #include <iostream>template<int X, int Y>struct cp {  static const int r = X * cp<X,Y-1>::r;};template<int X>struct cp<X,0> {  static const int r = 1;};int main() {  std::cout << cp<2,12>::r << std::endl;}  


Solve that. If you can''t, then you dont know C++ well enough.
Shouldn't that be an unsigned int for the Y template argument...

otherwise you'll get infinite (until it wraps!) recursion... (edit: if Y < 0 )

[edited by - Paradigm Shifter on September 4, 2002 12:23:13 PM]
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
Advertisement
quote: Original post by Tien Long
Solve that. If you can''t, then you dont know C++ well enough.


Thanks, Tien! I barely even use templates, but I managed to figure out what you''re doing! I admit it took me a minute, but my ego is somewhat inflated.

-Arek the Absolute
-Arek the Absolute"The full quartet is pirates, ninjas, zombies, and robots. Create a game which involves all four, and you risk being blinded by the sheer level of coolness involved." - Superpig
Well the notion that programming and anybody that knows alot about computers is a geek is largely a very wrong stereotype, I have a plethora of friends, have never been made fun of and am very much liked. I just keep my programming seperate from my everyday life AND it comes second, only when i have time will i program. I''m positive i''m not the only one.
Free Game Textures!!!http://www.vb3d.com/Textures.html
quote: Original post by EIGamerzX
Well the notion that programming and anybody that knows alot about computers is a geek is largely a very wrong stereotype, I have a plethora of friends, have never been made fun of and am very much liked. I just keep my programming seperate from my everyday life AND it comes second, only when i have time will i program. I''m positive i''m not the only one.


That''s fine, but in my opinion it''s okay to be a geek; it''s okay to be whatever you want to be. The world is stronger because of our differences, not in spite of our differences, so people should learn to respect each other rather than decide to not like them because they aren''t the same as them.

www.bankie.com
and hey, bill gates wasn''t even a geek realy... he was just EXTREAMLY devoted to programing. look at some of the people that started PCs they arn''t geeks. they wern''t then they arn''t now. they ate cold pizza drank coke and programed... that was thier life, and if that means they were geeks I will eat my socks. (realy... I will!)
Advertisement
quote: Original post by bobbias
and hey, bill gates wasn't even a geek realy... he was just EXTREAMLY devoted to programing. look at some of the people that started PCs they arn't geeks. they wern't then they arn't now. they ate cold pizza drank coke and programed... that was thier life, and if that means they were geeks I will eat my socks. (realy... I will!)


I don't care about what you said, I just want to see you eat your socks! I dare you. Post pics to prove it. Go on, you wuss, EAT em.

- CheeseMonger

[edited by - CheeseMonger on September 4, 2002 7:48:35 PM]
- CheeseMonger
For a crash course in "Getting along with people from widely dispursed socio-economic backrounds and widely varied intelligence levels" join the united states Army! I met some of the most amazing, profoundly stupid, annoying and dispicable people in there. I met a couple (only a couple mind you) of genuinly intelligent people (well, one anyway). Only when you are forced to eat, sleep, work with, and hangout with (and even shower with, its called "gang showers") the people you HATE everyday, day in and day out for YEARS, then you will learn how to get along with anyone.
quote: Original post by Tien Long
(compile-time power calculator)
Ah, but can you do it without partial template specialisation?

    template<int X, int Y>struct cp {  static const int guard = static_cast<int>(Y != 1); // insert evil laughter here  static const int r = X * cp<guard*X,Y-1>::r;};template<>struct cp<0,0> {  static const int r = 1;};  
(won't work for all inputs, I know)

[edited by - Beer Hunter on September 5, 2002 6:47:38 PM]

    int main() {      std::cout << cp<2,12>::r << std::endl;}    



you forgot to add return 0; in main function, since it's an integer function


In a corner by the door were thousands of switches. They were marked with words Linda did not understand: "Line... Feed... Load... Flipflop..."
But she could understand the small green signs under each switch. They all said, "On."
"You take half!" Al cried. He began to hit the switches with both hands. He was turning off five at a time. Red lights began to flash. They said, "Off... Off... Off."

Exactly what we need to do with Windows.

[edited by - Zeraan on September 6, 2002 4:58:57 PM]

[edited by - Zeraan on September 6, 2002 4:59:42 PM]

This topic is closed to new replies.

Advertisement