PDA

View Full Version : [SOLVED] Bottles of beer on the wall?



ThatCoolGuy220
July 1st, 2011, 02:11 AM
Hi idk why it was closed but i would like to share what i did with the first challenge:

Warning Windows:



#include <cstdio>
#include <cstdlib>
#include <windows.h>
#include <iostream>
#include <string>

using namespace std;

int main()
{

int a;
string c, d, e, f, F, s;

c = " bottles of beer on the wall, ";
d = " bottles of beer";
e = "Take one down and pass it around, ";
f = " no more bottles of beer on the wall";
F = "No more bottles of beer on the wall";
s = "Go to the store and buy some more, ";

for (a = 99; a > 1; a --)
{

cout << a << c << a << d << endl << e << a - 1 << c << endl << endl;


}

cout << a << c << a << d << endl << e << f << endl << endl << F << " no more " << d << endl;

a = 99;

cout << s << a << c;



cin.get();
return 0;
}


For Linux it would be like this:



#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int main()
{

int a;
string c, d, e, f, F, s;

c = " bottles of beer on the wall, ";
d = " bottles of beer";
e = "Take one down and pass it around, ";
f = " no more bottles of beer on the wall";
F = "No more bottles of beer on the wall";
s = "Go to the store and buy some more, ";

for (a = 99; a > 1; a --)
{

cout << a << c << a << d << endl << e << a - 1 << c << endl << endl;

Sleep(8000);

}

cout << a << c << a << d << endl << e << f << endl << endl << F << " no more " << d << endl;

a = 99;

cout << s << a << c;



cin.get();
return 0;
}



I think the sleep(); function, Sleep(); on Windows, could be added for sing along LOL too bad was closed was a good thread.

juancarlospaco
July 1st, 2011, 02:20 AM
...I was thinking of Bottle (http://www.bottlepy.org) framework :(

ThatCoolGuy220
July 1st, 2011, 02:22 AM
Por tu nombre creo que hablas español no?

schauerlich
July 1st, 2011, 03:27 AM
Just a tip - use better variable names. abcdef is not a good way to go through life.

No sabías? Todos hablamos español.

Pues... quizás no todos. Pero no me importan lo otros. :)

ThatCoolGuy220
July 1st, 2011, 06:19 AM
XD

Nooo no lo sabia jeje.

Yes those variable names arent that creative, but for a beginer is ok

Tony Flury
July 1st, 2011, 10:10 AM
Just curious - why in your "windows" version do you include windows.h - and then it seems not use anything from it.

I would have thought that your linux version would compile perfectly on windows - the only difference between the two versions is the Sleep function you use in your "linux" version.

ThatCoolGuy220
July 1st, 2011, 10:56 PM
Cause I Have my templates that way, and I was using the Sleep idea but not for the presentation