Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualSutayh

Posted 11 February 2014 - 02:56 AM

Just throwing my hat in the ring, though it's not the shortest:

#include<iostream>
#include<sstream>
using namespace std;
string m="o more",v=" bottle",t=" of beer",s=" on the wall";
string a(int n,int c=0)
{
stringstream b;
b << n;
return (n?b.str():(c?"N":"n")+m)+(n==1?v:v+"s");
}
int main()
{
for(int l=99;l>-1;--l)
{
cout << a(l,1)+t+s+", "+a(l)+t+".\n"+(l?"Take one down and pass it around, ":"Go to the store and buy some more, ")+(a(l?l-1:99))+t+s+".\n\n";
}
} 

370 characters, 332 without "any" whitespace.


#4Sutayh

Posted 11 February 2014 - 02:54 AM

Just throwing my hat in the ring, though it's not the shortest:


#include<iostream>
#include<sstream>
using namespace std;
string m="o more",v=" bottle",t=" of beer",s=" on the wall";
string a(int n,int c=0)
{
stringstream b;
b << n;
return (n?b.str():(c?"N":"n")+m)+(n==1?v:v+"s");
}
int main()
{
for(int l=99;l>-1;--l)
{
cout << a(l,1)+t+s+", "+a(l)+t+".\n"+(l?"Take one down and pass it around, ":"Go to the store and buy some more, ")+(a(l?l-1:99))+t+s+".\n\n";
}
}

370 characters, 332 without "any" whitespace.


#3Sutayh

Posted 10 February 2014 - 12:22 PM

Just throwing my hat in the ring, though it's not the shortest:

#include<iostream>
#include<sstream>
using namespace std;
string m="o more",v=" bottle",t=" of beer",s=" on the wall";
string a(int n,int c=0)
{
stringstream b;
b << n;
return (n?b.str():(c?"N":"n")+m)+(n==1?v:v+"s");
}
int main()
{
for(int l=99,o=98;l>-1;l=o--)
{
cout << a(l,1)+t+s+", "+a(l)+t+".\n"+(l?"Take one down and pass it around, ":"Go to the store and buy some more, ")+(a(l?o:99))+t+s+".\n\n";
}	
}

375 characters, 337 without whitespace.


#2Sutayh

Posted 10 February 2014 - 12:06 PM

Just throwing my hat in the ring, though it's not the shortest:

#include<iostream>
#include<sstream>
using namespace std;
string m="o more",v=" bottle",t=" of beer",s=" on the wall";
string a(int n,int c=0)
{
stringstream b;
b << n;
return (n?b.str():(c?"N":"n")+m)+(n==1?v:v+"s");
}
int main()
{
for(int l=96,o=95;l>-1;l=o--)
{
cout << a(l,1)+t+s+", "+a(l)+t+".\n"+(l?"Take one down and pass it around, ":"Go to the store and buy some more, ")+(a(l?o:99))+t+s+".\n\n";
}	
}

375 characters, 337 without whitespace.


#1Sutayh

Posted 10 February 2014 - 02:20 AM

Just throwing my hat in the ring, though it's not the shortest:

#include<iostream>
#include<sstream>
using namespace std;
string m=" more",v=" bottle",t=" of beer",s=" on the wall";
string a(int n,int c=0)
{
stringstream b;
b << n;
return (n?b.str():(c?"No":"no")+m)+(n==1?v:v+"s");
}
int main()
{
for(int l=96,o=95;l>-1;l=o--)
{
cout << a(l,1)+t+s+", "+a(l)+t+".\n"+(l?"Take one down and pass it around, ":"Go to the store and buy some more, ")+(a(l?o:99))+t+s+".\n\n";
}	
}

376 characters, 338 without whitespace.


PARTNERS