Jump to content

32bites

Active Members
  • Posts

    13
  • Joined

  • Last visited

Posts posted by 32bites

  1. Trying to decipher this. Do you mean you wish to know the forumla for Pi?  ... C/D      Circumference over diameter. You could just find a predefined circle circumference and diameter but hey :D

    Yes but to do that I would need 2 constants pulled out of my ass. What I am trying to trying to figure out how to figure out what Pi is.

    Over the weekend my dad helped me do this (and while doing it decided to rewrite all my code). It now gives out the numbers every 100000 points. It now evens out to about  3.141522, I think this is due to the to the fact that rand() is not that random or some how the numbers are wrong.

    // I will foo your bar
    
    #include <iostream>
    using namespace std;
    #include <cmath>
    #include <time.h>
    #include <stdio.h>
    
    #define range   32768
    
    int main ()
    {
        double count = 0;
        double inside = 0;
        int q=0;
        
        srand ( time(NULL) );
        cout << "Starting. n";
        while(1) 
        {
            int x = rand() % range;
            int y = rand() % range;
            inside += (x*x + y*y < (range-1)*(range-1));
            count++;
            q++;
            if(q>=100000)
            {
                printf("inside=%.0f count=%.0f ratio=%18.16fn",inside, count,inside*4/count);
                q=0;
            }
        } 
    
        return 0;
    }

  2. I am working on trying to generate Pi with C++. How it should work is it gets the ratio of area in a circle to the area outside a circle within a square where the diameter of the circle is the same as the width of the square (it seems to be about 3.66:1).

    I want to know if there is formula to find Pi using this.

    // I will foo your bar
    
    #include <iostream>
    using namespace std;
    #include <cmath>
    #include <time.h>
    
    
    int main ()
    {
        cout << "Setting variablesn";
        int range = 32768,pointamount = 259499, z = 0;
        cout << "Done setting variables nSetting up float variablesn";
        float distance, x[pointamount], y[pointamount], pie, incircle = 0, outcircle = 0;
        cout << "Done setting float variables n";
        
        srand ( time(NULL) );
        cout << "Starting. n";
        while(z <= pointamount) 
        {
                x[z] = rand() % range;
                y[z] = rand() % range;
                cout << z << "n";
                z++;
        }
        cout << "Done with generating x[z] and y[z]n";
        z = 0;
        
        while(z <= pointamount)
        {
                //find distance
                distance = sqrt( pow(x[z], 2) + pow(y[z], 2) );
                if( distance <= range)
                {
                    incircle++;
                } 
                else
                { 
                    outcircle++;
                }
                z++;
        } 
        
        cout << "Amount inside circle: " << incircle <<"n";
        cout << "Amount outside circle: " << outcircle <<"n";
        cout << "incircle / outcircle = " << incircle / outcircle <<"n";
        cout << "inside + circle = " << incircle + outcircle <<"n";
        system("PAUSE");
        return 0; //guess what
    }

  3. Thanks you your help I found a friend of mien to help me with this he came up with this:

    // I will foo your bar
    
    #include <iostream>
    #include <cmath>
    #include <cstdlib>
    using namespace std;
    
    int main ()
    {
        float x1, x2, y1, y2, x, y, d;
        float midordist;
    
        cout << "nDo you want to find the midpoint (1), the distance (2), or both (3): ";
        cin >> midordist;
    
        if(midordist < 1 || midordist > 3) {
            cout << "nThe option you have enterd is not valid";
            return 0;
        }
    
        cout << "nnPlese enter in the form (x1, y1) and (x2, y2)n";
    
        cout << "x1 = ";
        cin >> x1;
    
        cout << "y1 = ";
        cin >> y1;
    
        cout << "nThe first set is (" << x1 << ", " << y1 << ")nn";
    
        cout << "x2 = ";
        cin >> x2;
    
        cout << "y2 = ";
        cin >> y2;
    
        cout << "nThe second set is (" << x2 << ", " << y2 << ")nn";
    
        if(midordist == 1 || midordist == 3){ //find midpoint
            x = (x1 + x2) / 2;
            y = (y1 + y2) / 2;
            cout << "The midpoint of (" << x1 << ", " << y1 << ") and (" << x2 << ", " << y2 << ") is (" << x << ", " << y << ")";
        }
        if(midordist == 3){
            cout << "n";
        }
        if(midordist == 2 || midordist == 3){ //find distance
            x = pow(x2 - x1, 2);
            y = pow(y2 - y1, 2);
            d = sqrt(x+y);
            cout << "The distance between (" << x1 << ", " << y1 << ") and (" << x2 << ", " << y2 << ") is " << d;
        }
    
        return 0;
    }

    This mainly ads || midordist == 3 to each if statement. along with adding n between the two results.

  4. A am learning C++. I am currently trying to figure out a way for a user to have an option to do both A and B in addition to A or B.

    So far i have put in an option to to A and B but I dont know the best way for it to actually do both.

    // I will foo your bar
    
    #include <iostream>
    #include <cmath>
    using namespace std;
    
    int main ()
    {
        float x1, x2, y1, y2, x, y, d;
        float midordist;
    
        cout << "nDo you want to find the midpoint (1), the distance (2), or both (3): ";
        cin >> midordist;
    
        if(midordist < 1 || midordist > 3) {
            cout << "nThe option you have entered is not valid";
            return 0;
        }
    
        cout << "nnPlese enter in the form (x1, y1) and (x2, y2)n";
    
        cout << "x1 = ";
        cin >> x1;
    
        cout << "y1 = ";
        cin >> y1;
    
        cout << "nThe first set is (" << x1 << ", " << y1 << ")nn";
    
        cout << "x2 = ";
        cin >> x2;
    
        cout << "y2 = ";
        cin >> y2;
    
        cout << "nThe second set is (" << x2 << ", " << y2 << ")nn";
    
        if(midordist == 1){ //find midpoint
            x = (x1 + x2) / 2;
            y = (y1 + y2) / 2;
            cout << "The midpoint is (" << x << ", " << y << ")";
        }
    
        if(midordist == 2){ //find distance
            x = pow(x2 - x1, 2);
            y = pow(y2 - y1, 2);
            d = sqrt(x+y);
            cout << "The distance between (" << x1 << ", " << y1 << ") and (" << x2 << ", " << y2 << ") is " << d;
        }
    
        return 0;
    }

  5. I was just looking through a magazine and I saw that Vista had cut the price of Vista on both the upgrade and full version.  The magazine only mentioned Ultimate and Premium but whatever.  I got me thinking, could you buy an upgrade version of Vista, download a full version from a torrent site, and use the key that came with the version you bought?  Is that within the right of the EULA?  You would save yourself some cash but would Microsoft me mad at you?

    What you can do is buy an upgrade version install ti without putting in the serial number, it gives you 30 days to put it in. After that is done you can put the installer in again  and chose to preform an upgrade and you just got vista for cheaper.

    You could also just find a copy of XP or something lying around and put that on first.

  6. Please forgive my ignorance.

    I can read up tomorrow on the proxy and to install firefox would i need to ininstall IE or leave it alone and just launch off of firefox. 

    A problem i might see is that i can not install any .exe without being an admin.

    If you cant install firefox you may want to try firefox portable, it is a copy of firefox that keeps itself and settings on a USB drive.

    http://portableapps.com/apps/internet/firefox_portable

    Use a proxy?

    And if you just want to go to a website try: http://yxorp.32bites.com. I run it on my server and hasn't been blocked anywhere I know of yet.

  7. THATS INSANE!

    Wow, thats so cool. How did they do that!

    They just have 3d model that moves with animations for each syllable.

    And for using any picture, the image's head wont turn much so its not that noticeable with the textures on the sides of the cheek and under the chin get stretched a bit.

  8. I have recently spend a few hours trying to make a guide on how to rip songs from Pandora on Vista and XP.

    You will need:

    PandoraRip

    Any version of firefox. http://getfirefox.com

    Flash Player 8

    1.) Download ripping client

    The only one that i found that gets ID3 tags and album art is 'PandoraRip'

    You can get it from http://www.geopacket.com/PandoraRip/.

    There is more information on it at http://forums.hak5.org/index.php/topic,8024.0.html.

    2.) install FLASH 8

    I got it from http://kb.adobe.com/selfservice/viewConten...rnalId=tn_14266 (adobe).

    Close all browsers.

    uninstall all earlier versions of flash.

    Extract the fp8_archive.zip to a folder.

    Install flashplayer8r22_win.exe and flashplayer8r22_winax.exe under .fp8_archivefp8_archiver22

    3.) XP SP2 Compatibility mode and administrator. (VISTA ONLY)

    Go to properties on PandoraRip-1070.exe

    width=404 height=576http://32bites.com/img/pandoraripproperties.png[/img]

    Set Compatibility mode to 'Windows XP (Service Pack 2)'

    Check 'Run this program as an administrator'. (needed to read firefox cache files)

    width=487 height=528http://32bites.com/img/pandoraripproperties2.png[/img]

    Go to properties on Firefox

    width=321 height=550http://32bites.com/img/firexofproperties.png[/img]

    Set Compatibility mode to 'Windows XP (Service Pack 2)'

    width=472 height=535http://32bites.com/img/firexofproperties2.png[/img]

    4.) Run PandoraRip

    Run PandoraRip-1070.exe.

    Go to the 'Terms of Service Tab'.

    Check 'I accept and agree to be bound by the Terms of Service EULA'.

    width=540 height=315http://32bites.com/img/pandorariptos.png[/img]

    Click 'Rock On'. (minimizes it to system tray)

    5.) Open firefox.

    Open firefox and go to http://pandora.com/

    PandoraRip will tell you when you download new songs.

    (Pandora must stay open for it to keep getting songs)

    6.) Engoy the music.

    Your music will be in the 'PandoraRip' folder on your desktop.

  9. Uninterpreted compiled languages are able to run much more efficiently than any interpreted language.

    C is compilable in to machine language that the hardware of a computer can understand and run, this is what is used to create the majority of OS's, or at least the kernel, Including, but not limited to, Windows, Linux and OS X.

    A compiler takes the instructions you wrote, links them with any libraries you required (in C these would be header files) and converts them (compiles) in to machine code, the language of the computer. This can then be run on a computer.

    Unless you specifically write your code to be so, C code is not necessarily cross platform. While Compiled C code is able to run on the hardware of a computer, if you compile a program that is specifically for windows (meaning, you probably included a windows specific library), it probably wont run on Linux or OS X with out either modifying the code to implement the Linux/OS X equivalent of the windows library. Another option may also be to use a windows like environment (WINE).

    Advantages:

    Runs more efficiently than interpreted language

    Hides source code

    Computer hardware is able to run C

    Disadvantages:

    Harder to code (relatively speaking to php)

    Thanks of the help, that answers my question.

  10. I have only written PHP and basic perl on web servers. I wanted to got in to C but I don't understand exactly what a complier does. And what the advantage of compiling code over giving source code to be interpreted.

×
×
  • Create New...