Jump to content

32bites

Active Members
  • Posts

    13
  • Joined

  • Last visited

Everything posted by 32bites

  1. 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. 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. 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 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. http://32bites.com/desktop.jpg[/img]
  8. 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.
  9. Not for this way, it installs Flash 8 to the local machine.
  10. 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 http://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) http://32bites.com/img/pandoraripproperties2.png[/img] Go to properties on Firefox http://32bites.com/img/firexofproperties.png[/img] Set Compatibility mode to 'Windows XP (Service Pack 2)' http://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'. http://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.
  11. Thanks of the help, that answers my question.
  12. 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.
  13. I'm going to get some. But i was wondering how many stickers come in a 'pack'.
×
×
  • Create New...