Welcome, Guest. Please login or register.

Author Topic: C++ post your shitt  (Read 5378 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
  • Careful what you post. Forum rules still apply in the shoutbox!
  • Pyro: happy birthday Tyber
    July 14, 2024, 01:55:16 PM
  • Finniespin: More of a Patrick Hernandez guy - Born to be Alive
    June 16, 2024, 09:14:27 AM
  • Sly: Aaron Hernandez was a legend of a man
    June 14, 2024, 01:46:02 AM
  • Finniespin: how? what?
    June 01, 2024, 06:28:43 PM
  • Inject OH 4: Lost my discord rip
    May 30, 2024, 12:14:57 AM
  • Finniespin: yoooooooo!
    April 03, 2024, 05:32:48 PM
  • Coreybush11: bump
    April 01, 2024, 10:59:48 PM
  • Finniespin: wut
    March 28, 2024, 05:01:26 PM
  • Inject OH 4: And yes thank you very much Finnie! You are a champion xP
    March 22, 2024, 05:59:12 PM
  • Inject OH 4: Hey abrys agreed we should.
    March 22, 2024, 05:59:02 PM
  • Finniespin: Totally not a spam-bot, also totally not a limited time offer
    March 03, 2024, 05:25:06 PM
  • Finniespin: Anyone looking for a datacenter technician job? We got postings available around US and Europe (EMEA)
    February 17, 2024, 07:23:12 AM
  • Finniespin: https://www.google.com/about/careers/applications/jobs/results/118336179041903302-data-center-technician-global-server-operations
    February 17, 2024, 07:20:25 AM
  • Finniespin: Gave Inject 50 euros to pay for fees ^^
    February 17, 2024, 07:17:42 AM
  • xXArbysOvenMittXx: we gotta get the crew together again one day and hang, add me on discord: ogarbies
    February 12, 2024, 06:52:07 PM
  • xXArbysOvenMittXx: yo who is still paying for this lol
    February 12, 2024, 06:19:47 PM
  • Klondor: wow CG still lives, mind blown
    February 09, 2024, 05:13:53 AM
  • Finniespin: The website is back online!!!
    February 06, 2024, 03:17:05 PM
  • Inject OH 4: xD
    January 14, 2024, 05:55:44 PM
  • Finniespin: Get a load of this guy
    December 16, 2023, 09:16:03 AM
  • Inject OH 4: Sure
    December 09, 2023, 07:22:27 PM
  • HailToTheKing: cum shot . and cum shot. an d cum shot
    December 01, 2023, 01:54:12 PM
  • Finniespin: ffuck
    November 24, 2023, 03:43:47 PM
  • Inject OH 4: ee
    October 12, 2023, 01:13:56 AM
  • Sly: dd
    August 09, 2023, 03:13:48 AM
  • Inject OH 4: cc
    August 03, 2023, 09:51:36 PM
  • Finniespin: bb
    August 02, 2023, 06:12:50 PM
  • Inject OH 4: aa
    July 04, 2023, 10:29:35 PM
  • Shikaru: Been a very long time
    February 20, 2023, 05:42:04 PM
  • Shikaru: Oh wow my account is STILL active :)
    February 20, 2023, 05:42:00 PM
  • Napoleon BonaPARTY: yooo we got a lovense sponsor???
    December 16, 2022, 03:45:43 PM
  • Napoleon BonaPARTY: holy shit
    December 16, 2022, 03:45:24 PM
  • Napoleon BonaPARTY: oh wow its still here
    December 16, 2022, 03:45:21 PM
  • HailToTheKing: legends never die
    October 16, 2022, 01:28:09 PM
  • Live Bait: Oh wow. Still remember my old password.
    September 23, 2022, 08:37:38 AM
  • Mr_Rainbow: Still alive. Hope all is well with everyone this Christmas
    December 09, 2021, 03:31:04 AM
  • SlyWilliam: Much love, from our MC server to our ZPS server <3
    December 07, 2021, 10:23:37 PM
  • SlyWilliam: For the record, I don't REALLY remember all of you, but goddamn do I MISS all of you <3
    December 07, 2021, 10:23:10 PM
  • Pyro: parrot
    September 07, 2021, 05:23:18 AM
  • Inject OH 4: Do you mean for people that haven't come on in a long time and have to reagree?
    August 02, 2021, 11:39:42 PM

SimplePortal 2.3.5 © 2008-2012, SimplePortal