Welcome, Guest. Please login or register.

Author Topic: C++ post your shitt  (Read 3962 times)

0 Members and 1 Guest are viewing this topic.

Offline Blackllama

C++ post your shitt
« on: May 30, 2011, 06:38:47 PM »
I've decided to review some of my c++, I wrote some useless codes and now I'm gonna make a quick number guessing game.  If you have any cool c++ programs post them plox.

Code: [Select]
#include <iostream>
#include <ctime>
using namespace std;
int main ()
{
   main:
   srand(time(NULL));
   unsigned char n =  rand() % 100+1;
   int g;
   cout << "Guess a number between 1 and 1oo (you get cake if you win): ";
   while (g != n) {
   cin >> g;
   if (g > n)
      cout << "\nLower: ";
     
   else if (g < n)
      cout << "\nHigher: ";
   }
   cout << "You win!  Congradulations.  Sorry, no cake, it was a lie.\n";
   goto main;
   return 0;
}
« Last Edit: May 30, 2011, 07:29:12 PM by Blackllama »

Offline Inject OH 4

Re: C++ post your shitt
« Reply #1 on: May 31, 2011, 02:51:18 AM »
ahh the classic Number game.

Yeah,
Quote from:  Winston
We shall defend our island, whatever the cost may be, we shall fight on the beaches, we shall fight on the landing grounds, we shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender.
Quote from:  Zombie
Valuve Admin Steve: If not we at valve can act as a "guardian gateway".
Valuve Admin Steve: I will be your daddy.
Looking for graphic artist, Photoshopers, and other graphic related people. Hit me a PM if you can help!

Conjoint Gaming [Game On]

Re: C++ post your shitt
« Reply #1 on: May 31, 2011, 02:51:18 AM »

Offline Finniespin

Re: C++ post your shitt
« Reply #2 on: May 31, 2011, 05:54:03 AM »
:< I think C# is horrible already...

Here's aspx. (Some dutch content)
Nevermind stored it locally.

Posting soon!

Offline Acecool

Re: C++ post your shitt
« Reply #3 on: May 31, 2011, 06:47:02 PM »
I made a subscription based application that plays an RPG for you without breaking the TOS. Its a few thousand lines though...

Offline Guvnuh

Re: C++ post your shitt
« Reply #4 on: May 31, 2011, 07:56:15 PM »
Code: [Select]
#include <iostream>
using namespace std;

int main(void)
 {
cout<<"░░░░░▄▄▄▄▀▀▀▀▀▀▀▀▄▄▄▄▄▄░░░░░░░"<<endl;
cout<<"░░░░░█░░░░▒▒▒▒▒▒▒▒▒▒▒▒░░▀▀▄░░░░"<<endl;
cout<<"░░░░█░░░▒▒▒▒▒▒░░░░░░░░▒▒▒░░█░░░"<<endl;
cout<<"░░░█░░░░░░▄██▀▄▄░░░░░▄▄▄░░░░█░░"<<endl;
cout<<"░▄▀▒▄▄▄▒░█▀▀▀▀▄▄█░░░██▄▄█░░░░█░"<<endl;
cout<<"█░▒█▒▄░▀▄▄▄▀░░░░░░░░█░░░▒▒▒▒▒░█"<<endl;
cout<<"█░▒█░█▀▄▄░░░░░█▀░░░░▀▄░░▄▀▀▀▄▒█"<<endl;
cout<<"░█░▀▄░█▄░█▀▄▄░▀░▀▀░▄▄▀░░░░█░░█░"<<endl;
cout<<"░░█░░░▀▄▀█▄▄░█▀▀▀▄▄▄▄▀▀█▀██░█░░"<<endl;
cout<<"░░░█░░░░██░░▀█▄▄▄█▄▄█▄████░█░░░"<<endl;
cout<<"░░░░█░░░░▀▀▄░█░░░█░█▀██████░█░░"<<endl;
cout<<"░░░░░▀▄░░░░░▀▀▄▄▄█▄█▄█▄█▄▀░░█░░"<<endl;
cout<<"░░░░░░░▀▄▄░▒▒▒▒░░░░░░░░░░▒░░░█░"<<endl;
cout<<"░░░░░░░░░░▀▀▄▄░▒▒▒▒▒▒▒▒▒▒░░░░█░"<<endl;
cout<<"░░░░░░░░░░░░░░▀▄▄▄▄▄░░░░░░░░█░░"<<endl;

return 0;
}

Offline Blackllama

Re: C++ post your shitt
« Reply #5 on: June 01, 2011, 01:57:02 AM »
Code: [Select]
#include <iostream>
using namespace std;

int main(void)
 {
cout<<"░░░░░▄▄▄▄▀▀▀▀▀▀▀▀▄▄▄▄▄▄░░░░░░░"<<endl;
cout<<"░░░░░█░░░░▒▒▒▒▒▒▒▒▒▒▒▒░░▀▀▄░░░░"<<endl;
cout<<"░░░░█░░░▒▒▒▒▒▒░░░░░░░░▒▒▒░░█░░░"<<endl;
cout<<"░░░█░░░░░░▄██▀▄▄░░░░░▄▄▄░░░░█░░"<<endl;
cout<<"░▄▀▒▄▄▄▒░█▀▀▀▀▄▄█░░░██▄▄█░░░░█░"<<endl;
cout<<"█░▒█▒▄░▀▄▄▄▀░░░░░░░░█░░░▒▒▒▒▒░█"<<endl;
cout<<"█░▒█░█▀▄▄░░░░░█▀░░░░▀▄░░▄▀▀▀▄▒█"<<endl;
cout<<"░█░▀▄░█▄░█▀▄▄░▀░▀▀░▄▄▀░░░░█░░█░"<<endl;
cout<<"░░█░░░▀▄▀█▄▄░█▀▀▀▄▄▄▄▀▀█▀██░█░░"<<endl;
cout<<"░░░█░░░░██░░▀█▄▄▄█▄▄█▄████░█░░░"<<endl;
cout<<"░░░░█░░░░▀▀▄░█░░░█░█▀██████░█░░"<<endl;
cout<<"░░░░░▀▄░░░░░▀▀▄▄▄█▄█▄█▄█▄▀░░█░░"<<endl;
cout<<"░░░░░░░▀▄▄░▒▒▒▒░░░░░░░░░░▒░░░█░"<<endl;
cout<<"░░░░░░░░░░▀▀▄▄░▒▒▒▒▒▒▒▒▒▒░░░░█░"<<endl;
cout<<"░░░░░░░░░░░░░░▀▄▄▄▄▄░░░░░░░░█░░";
system("pause>nul");
return 0;
}

That is how it should look lol.  First of all, It doesn't look anywhere near a troll face in the cmd line.  Second, I added the
Code: [Select]
system("pause>nul"); because if you didn't, it would just close as soon as it ran.  Son, I am disappoint.

EDIT:

Also, I wrote a few programs on the TI-84 calculator like the Pythagorean theorem, and I re-wrote it in c++.  I may have written the same thing on python at one point as well, which, let me just say, is much better for mathematics.  C++ just makes it a pain, none the less I still made one.

Here.
Code: [Select]
#include <iostream>
#include <math.h>
using namespace std;

int main ()
{
cout << "Pythagorean theorem calculator." << endl << "~~~~~~~~~~~~~~~~~~~~~~~~~" << endl << "Enter a: ";
int a, b;
cin >> a;
system("CLS");
cout << "Enter b: ";
cin >> b;
system("CLS");
cout << "c = " << sqrt(pow(a, 2)+pow(b, 2)) << "."
system("pause>nul");
return 0;
}

« Last Edit: June 01, 2011, 02:53:28 AM by Blackllama »

Offline Acecool

Re: C++ post your shitt
« Reply #6 on: July 03, 2011, 11:43:06 PM »
1800 lines on here? Meh... If anyone wants to buy some code for Ashen Empires to bypass the macro check, let me know :-)

Offline Burgers-13

Re: C++ post your shitt
« Reply #7 on: October 30, 2013, 04:24:36 AM »
so taking a c++ course and im not learning diddly quawt from my teacher even tho shes really nice.. i have resorted to youtube and online help which is helping but it could only go so far..

im a total noob and im trying to make something as simple as a calculator for a food charge ex:

should ask you for the food charge and calculate the amount of a 18% tip and 7% sales tax and the toTAL.


this is what i have so far:


#include <iostream>
using namespace std;

int main()
{
   cout << "Enter charge for the food \n";
   const double PERCENT_TIP = 0.18;
      system("pause");
      return 0;
}


i dont know what function i put or how to put in the percentages into the code.  probably did that wrong helpeth

Offline Finniespin

Re: C++ post your shitt
« Reply #8 on: October 30, 2013, 10:00:55 AM »
:< I think C# is horrible already...

Here's aspx. (Some dutch content)
Nevermind stored it locally.

Posting soon!
OP SURELY DELIVERS...

Offline Christovski

Re: C++ post your shitt
« Reply #9 on: October 30, 2013, 11:53:36 AM »
Nice necro there Burgers :P

Luna started the rover's engine.  "AEIOU!" She shouted as she slammed the gas and crashed through the wall.
whenbananasattack: Hot stuff is my life
Toukun: I wanna rock the fuck out.
Ninja Bunn3h: !sex @all

Offline Blackllama

Re: C++ post your shitt
« Reply #10 on: October 30, 2013, 12:37:24 PM »
Me two years ago is just eww. I don't need to see this shit.

Offline Burgers-13

Re: C++ post your shitt
« Reply #11 on: October 30, 2013, 02:21:00 PM »
idk  ,, but i was just posting  where i thought  talking about c++ might go and maybe get some pointers... ima go sit in my darkest corner now  :-[

Offline Christovski

Re: C++ post your shitt
« Reply #12 on: October 30, 2013, 02:23:01 PM »
idk  ,, but i was just posting  where i thought  talking about c++ might go and maybe get some pointers... ima go sit in my darkest corner now  :-[

Don't be so afraid to start new threads Burgs :P

Luna started the rover's engine.  "AEIOU!" She shouted as she slammed the gas and crashed through the wall.
whenbananasattack: Hot stuff is my life
Toukun: I wanna rock the fuck out.
Ninja Bunn3h: !sex @all

Offline Leninade

Re: C++ post your shitt
« Reply #13 on: November 02, 2013, 04:22:58 PM »
so taking a c++ course and im not learning diddly quawt from my teacher even tho shes really nice.. i have resorted to youtube and online help which is helping but it could only go so far..

im a total noob and im trying to make something as simple as a calculator for a food charge ex:

should ask you for the food charge and calculate the amount of a 18% tip and 7% sales tax and the toTAL.


this is what i have so far:


#include <iostream>
using namespace std;

int main()
{
   cout << "Enter charge for the food \n";
   const double PERCENT_TIP = 0.18;
      system("pause");
      return 0;
}


i dont know what function i put or how to put in the percentages into the code.  probably did that wrong helpeth
First off, you need an int for your original input variable.
Second, you need to use the cin function to allow for input from the command window. The syntax should be something like cin >> variable_name;
Finally, you need to decide how the total is being calculated. Is the tip 18% of the original price, and the tax is 7% of that new total, or are they both applied to the original price?
 i.e. one formula would be variable_name*1.18*1.07, while the other would be something like variable_name* 1.18 + variable_name*.07.

From there, it's pretty easy. You just need to do a cout << with your variable name or whatever text you want, and you should be good.

#include <iostream>
using namespace std;

int main()
{
        int price;
        int total;
        const double PERCENT_TIP = 0.18;
        const double TAX = .07
   cout << "Enter charge for the food \n";
        cin >> price >> \n;
        total = price*PERCENT_TIP + price*TAX  + price;
        cout << "The final total is: " << total << \n;
   
      system("pause");
      return 0;
}


Arrows on the cin/cout might be backwards, but I don't have a compiler to make sure, and it's an easy fix. Also, when you write code, make sure you do all your variable/const/define declarations at the top of your program. I think you can declare stuff mid-program in something like MATLAB, but I don't think C++ really lets you do that, and even if it does, it's not good practice to do that.

Conjoint Gaming [Game On]

Re: C++ post your shitt
« Reply #13 on: November 02, 2013, 04:22:58 PM »

 


* ShoutBox!

Refresh History

SimplePortal 2.3.5 © 2008-2012, SimplePortal