Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - WhatevaGuy

Pages: [1] 2 3 4 5 6 ... 361
1
Off Topic / Re: WhatevaGuy is learning C++!
« on: June 05, 2011, 09:12:50 PM »
I predict a precision error

Use only whole numbers

What do you mean?  :o

2
Off Topic / Re: WhatevaGuy is learning C++!
« on: June 05, 2011, 09:10:37 PM »
Yeah, what about it?

3
Off Topic / WhatevaGuy is learning C++!
« on: June 05, 2011, 09:06:43 PM »
And he wants to show off a few select programs o:

Also I would like to invite you to show off your select few programs if you wish!  :D

Note - if you don't feel like reading all this, just skip down to the code or leave if you like, this is my excited rambling

Anyways, just for the record, I use CodeBlocks as a compiler and it is delightful and I would recommend it to everybody (never mind the fact that I've never used anything else).  I am learning through C++ For Dummies (I don't know if this is a quality book or not, but it's done a fairly good job of teaching me so far) and I have made a few programs on my own and a few programs that the book has told me to make.

I have included a WinRAR of every program I've made thus far, and the .exe is located in bin\debug I believe, so if you don't have a compiler to look at the code you can still see the results!

Also, if you do not have a compiler feel free to ask me for any source code, although I don't mean to flatter myself by saying y'all are indubitably enthralled by my delicious programming, I'm just saying the offer is there.

My favorite programs so far are the square number/cube number calculators.  I could easily have done a simple loop saying, "multiply n by itself, output that, add one to n, repeat" but I used a new algorithm that I made all by myself for both!
You'll see in the source code.

Also here's a list of the ones that I made because CppFD told me so:
  • booltest
  • breakdemo
  • loops

Just as a warning, there are a few very stupid ones that I made early on (especially 'template', I don't know why I made that) like 'death' and 'counter' but alas, I'm too lazy/packrattish to delete them.

Anyways here is the source to the cubenumbers, squarenumbers, and collatzConjectureTotal:

I actually have a set of hypotheses which I have created: "If x = y - 1, then x2 = y2 - (2y - 1)" and "If x = y + 1, then x2 = y2 + (2y + 1)"
Code: (squarenumbers) [Select]
//Lists square numbers up to a user-defined point.

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

using namespace std;

int main(int nNumberofArgs, char* pszArgs)
{
    //Set up all necessary variables.
    int square;
    int root;
    int additive;
    int limitdecision;
    int limit;

    //Define a few variables.
    square = 0;
    root = 0;
    additive = 1;
    cout << "Would you like a (0) root- or (1) square- limit? ";
    cin >> limitdecision;
    switch (limitdecision)
    {
        case 0:
            break;
        case 1:
            break;
        default:
            return 0;
    }
    cout << "Please enter the limit for the square numbers: ";
    cin >> limit;
    limit += 1;

    //Loop time!
    if (limitdecision == 0)
    {
        while (root < limit)
        {
            cout << square << " - " << root << endl;
            square += additive;
            root += 1;
            additive += 2;
        }
        system("PAUSE");
        return 0;
    }
    if (limitdecision == 1)
    {
        while (square < limit)
        {
            cout << square << " - " << root << endl;
            square += additive;
            root += 1;
            additive +=2;
        }
        system("PAUSE");
        return 0;
    }
}

I'll provide my equation as soon as I re-figure it out :(
Code: (cubenumbers) [Select]
//Lists square numbers up to a user-defined point.

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

using namespace std;

int main(int nNumberofArgs, char* pszArgs)
{
    //Set up all necessary variables.
    int cube;
    int root;
    int additive1;
    int additive2;
    int limitdecision;
    int limit;

    //Define a few variables.
    cube = 0;
    root = 0;
    additive1 = 1;
    additive2 = 6;
    cout << "Would you like a (0) root- or (1) cube- limit? ";
    cin >> limitdecision;
    switch (limitdecision)
    {
        case 0:
            break;
        case 1:
            break;
        default:
            return 0;
    }
    cout << "Please enter the limit for the cubed numbers: ";
    cin >> limit;
    limit += 1;

    //Loop time!
    if (limitdecision == 0)
    {
        while (root < limit)
        {
            cout << cube << " - " << root << endl;
            cube += additive1;
            additive1 += additive2;
            additive2 += 6;
            root += 1;
        }
        system("PAUSE");
        return 0;
    }
    if (limitdecision == 1)
    {
        while (cube < limit)
        {
            cout << cube << " - " << root << endl;
            cube += additive1;
            additive1 += additive2;
            additive2 += 6;
            root += 1;
        }
        system("PAUSE");
        return 0;
    }
}

http://en.wikipedia.org/wiki/Collatz_conjecture
Code: (collatzConjectureTotal) [Select]
//Collatz Conjecture - 1 can be derived from any integer if, while the integer is even,
//it is divided by two and, if it is odd, it is multiplied by three and increased by one.

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

using namespace std;

int collatzConjecture()
{
    int num;
    cout << "Please enter a number: ";
    cin >> num;
    system("CLS");

    //as long as the number is NOT one
    while(num != 1)
    {
        //output the number for client
        cout << num << endl;

        //check if the number is odd or even
        bool oddeven;
        oddeven = (num % 2 == 0);

        //take certain action, depending on whether num is odd or even
        switch(oddeven)
        {
            case 1:
                num = num/2;
                break;
            case 0:
                num = (num*3) + 1;
                break;
        }
    }

    cout << "1\n\n";
    cout << "Done!\n\n";
    system("PAUSE");
    return 0;
}

void collatzConjectureTwo()
{
    //setup...
    string oper;
    int delay;
    int num2;
    cout << "Starting number: "; //ask for starting number
    cin >> num2;
    cout << "Delay (millisecs): "; //ask for delaytime
    cin >> delay;

    //loop forever (unless user inputs 0 or less..)
    while (num2 > 0)
    {
        //clearscreen
        system("CLS");
        int num1 = num2; //set number1 to be number 2
        oper = "start"; //make sure this always reads 'start' on the first time
        while(num1 != 1) //as long as number1 is not 1..
        {
            cout << num1 << " - " << num2 << " - " << oper << endl; //output EVERYTHING
            Sleep(delay); //sleep for however long user wants
            bool oddeven; //test whether or not the number is even
            oddeven = (num1 % 2 == 0); //this is not the work of me, by the way, so don't go giving me credit for this line.  the rest is me though


            switch(oddeven)
            {
                case 1: //if even, divide by two
                    num1 = num1/2;
                    oper = "n/2";
                    break;
                case 0: //if odd, multiply by three and add 1
                    num1 = (num1*3) + 1;
                    oper = "3n+1";
                    break;
            }
        }
        cout << "1 - " << num2; //finish it up
        system("CLS");
        num2 += 1; //add one two num2 so we can do the same thing with the next number :D
    }
}

int main(int nNumberofArgs, char* pszArgs[])
{
    int collatzchoice;
    cout << "Collatz Conjecture 1 (1) or 2 (2)? ";
    cin >> collatzchoice;

    switch(collatzchoice)
    {
        case 1:
        system("CLS");
            collatzConjecture();
            return 0;
        case 2:
            system("CLS");
            collatzConjectureTwo();
    }
}

If explanation is needed for anything, go ahead and ask me.
By the way you can tell that I have gotten more wise with my use of functions.  It's very apparent in clock, less so in cct and nonexistant in mostly everywhere else

Anyways, please give me feedback and tips and perhaps ideas which are reasonable
And I would be happy to see some of your programs as well.

Archive of all my programs so far :D
http://foco.us/bpdO

4
Off Topic / Re: The Official Fashion Thread.
« on: June 05, 2011, 04:05:23 PM »
I wear slacks (or cargo pants, but I hate the notion of cargo pants) or jeans and collared button-down shirts.  I despise logos.  And a white undershirt if I can.
I generally forget what I'm wearing because I hardly ever actually pay attention to it, I just grab whatever two long-sleeved things I see.
I would wear nice shoes but they leave marks on the ground at school, and I wear ties occasionally.
What is that, fancy?

5
Off Topic / Re: Nearest famous location(s) by where you live.
« on: June 04, 2011, 06:15:11 PM »
Jamestown? lol

this :P
It's like, a ninety minute drive if I'm not mistaken :o

6
Off Topic / Re: Found some panties on my floor
« on: June 04, 2011, 12:19:58 AM »

7
Off Topic / Re: Found some panties on my floor
« on: June 04, 2011, 12:19:05 AM »
Smell them.
If it smells like your father, don't worry, he's just a transvestite, and not cheating on your step-mom.
Do it while your family's around, too, just in case you need a second opinion

8
Off Topic / Re: Dr. Kevorkian is dead
« on: June 03, 2011, 05:37:32 PM »
Noble work the man did.
It's a shame he's gone.

9
Off Topic / Re: How long can you go without breathing?
« on: May 31, 2011, 03:31:43 PM »
"I once held my breath for 30 minutes!"
kudos to whoever gets the reference

10
Off Topic / Re: CureAthritis
« on: May 30, 2011, 01:24:01 AM »
You seem like you need something to be mad about.  The increase in the amount of people with arthritis looks like about 50%.  The actual population will not grow that fast.

I'm not mad at all friend, I was pointing out a flaw I saw.
But now I understand, I'm an idiot when it comes to that and I realise now that twenty years is nowhere near enough to raise the population 150 million

11
Off Topic / Re: CureAthritis
« on: May 30, 2011, 12:55:14 AM »
Correct me if I'm wrong at all.
See Nexus' and my exchange

By the year 2030, you say 67 million people will have it?  From the current, what is it, like 46 million people today?
How am I supposed to take this fact seriously when you don't give me a percentage?  A ratio of healthy to not healthy.  Is that increasing, or is the population increasing and as a side effect that increases as well?
Say that five out of ten people in the year 1700 are cancerous.  There are also only ten people alive.  Say the population rises in one year by ten percent.  So in 1710, somebody could go around saying "holystuffholystuff ten people have cancer as compared to the five people ten years ago!" but it's actually a meaningless statement because that's still 1:2 so it's note like it's any different.
It's the same thing here - give me a percentage so I know that the amount of people with arthritis isn't just increasing because the entire population is increasing.  You seem to be trying to make it sound like a rising threat but if I'm right, and it's only increasing because the population is, it's not a rising threat at all.

12
Off Topic / Re: Post Your Desktop!
« on: May 29, 2011, 12:25:00 AM »
god dammit

also it was localized :c
it isnt TOO japanese

okay its really japanese
I don't recognize it, I just tineyed one of the little skulls :P

13
Off Topic / Re: Post Your Desktop!
« on: May 29, 2011, 12:22:17 AM »
i doubt many people will know what this skull design in particular is from

The World Ends With You, Japanese game, right?

14
Off Topic / Re: Post Your Desktop!
« on: May 28, 2011, 11:10:42 PM »
what could that one blurred out thing be...

oh that's nothing
But isn't it so beautiful?
It's alphabetically arranged and the background is lovey :D

15
Off Topic / Re: Post Your Desktop!
« on: May 28, 2011, 11:04:32 PM »

Pages: [1] 2 3 4 5 6 ... 361