2,712 Posted Topics
Re: Its because you don't have your normals calculated for rectangles. Plus put your lighting function in our initGL function. | |
Re: >>like if I have 0000.9876 will be stored as 9876 If this is exact then, you are making it too complicated. Just have a variable that starts where the string has the '.' character then increment it by one and then copy it. [code] string S = "000.123"; int stringIndx … | |
Re: just do this : [code] string input; string s = "$$$"; ifstream iFile("ReadMe.txt"); while(getline(iFile,input)) { if(input == s) break; else cout<<input<<endl; } [/code] Haven't tried it but that logic should work. | |
Re: >> How will i recognize the need of using the copy constructor ? Usually when you have a class that uses dynamic memory then you need to create your own copy constructor so when copying a value, each variable has its own memory location for its member variables. For example … | |
Re: >>i not sure what is the single quote means... Its usually used with char variables : [code] char quit = 'n'; if( quit == 'n' ) cout<<"Still playing\n"; [/code] | |
Re: cant you just do this : [code] void xSinX(int * A, int SZ, int lim){ for(int i = 0; i < lim && i < SZ; i++){ A[i] = i*sin( float(i) ); //xsin(x) } } [/code] | |
Re: [QUOTE=gretty;1033522]Hello I am not sure if my function below will completely delete a linked list. I am worried it will delete every element of the list except for the head(first node)? For example; If I have this linked list below Will my function delete the 1st node (1)? [CODE] void … | |
Re: Maybe the quality of the game and/or the features of the game is not supported by your video card. | |
Re: [QUOTE=Towely;1033614]Here's my code. [CODE]int main () { int input; cout <<"Enter a sequence of numbers (0 to quit): "; cin >> x; if (x != 0) { if (x % 2 == 0) { cout << x << " is even" << endl; } else if (x % 2 != … | |
Re: Just for trial, try putting : using namespace SAMSErrorHandling; at the top of your main. | |
Re: Suggestions from a college student : Reasons on why some Professors are better than other 1) Enthusiastic about their subject. 2) Knowledgeable about their subject 3) Clear with explanation 4) Start from basic to advance 5) Be descriptive on even the small things 6) Realize that the MOST easy thing … | |
Re: Good start, now first implement isPrime function first, and test it out with a loop from 0 to 100. Remember a prime number can only be a prime if it is only EVENLY divisible by itself and 1. That means if the mod operator return testPrime % index== 0 is … | |
Re: How about you give it a go and we'll see how it goes from there. Be sure to use code tags when posting code. | |
Re: [QUOTE=restrictment;1032043]Ah, ok. I tried this...but it still doesn't work: [code] ...... if(info == 'c') { gauge[0]='C'; gauge[1]='F'; values(float value1[11]); for(int x=0;x<=10;x++) value2[x]=(value1[x]*9)/5+32; } else { gauge[0] = 'F'; gauge[1] = 'C'; values(float value1[11]); for(int x=0;x<=10;x++) value2[x] = ((value1[x] - 32) * 5)/9; } ............... [/code][/QUOTE] your function call should be … | |
Re: You get seg fault. because your overflowing stack. It seems that you want a number ranging from 0.1 to 0.999 Look [URL="http://www.daniweb.com/code/snippet217455.html"]here[/URL] | |
Re: //if the file is exactly like that then you can do this : [code] ifstream iFile("file.txt"); string str ; float num1; float num2; float num3; iFile >> str; //read the string iFile >> num1 >> num2 >> num3; //read the number [/code] If you wan't something else be clearer. | |
Re: Sure, but first be clear in your question. How to make a table is a vague question. Exactly what kind of table do you have in mind? | |
Re: How about dynamically allocating your Node, then your return type can be of Node***. Alternative, you can use 3d vectors and have the return types as 3d vectors as well. | |
Re: >>Hi there, Hello there. >>I am new in java and some basic help would be appreciated. e.g Ok lets see... >>1-What's the out put of; >>double number = (1/3)*3; >>System.out.println("(1/3)*3 is equal to " + number); >>What's missing? Did you try this out on a compiler ? Is this a … | |
Re: You need to set the stream flags, look below : [code] cout<<fixed; //make it so that 3.000 comes out instead of 3 cout.precision(2); // make it so that 3.00 comes out [/code] Now when you print something like cout << GPA << endl; and if GPA is a whole number … | |
Re: In your first post you haven't defined a name within scope. I think what you are trying to is something like this : [code] #include<iostream> #include<string> using namespace std; class Test { string name; public : Test(string str) { name = str; } Test() { name = "NULL"; } void … | |
Re: >> However, when rotating a cube, my cube slowly shrinks. Is this s result of loss of accuracy in Math.sin() and Math.cos()? Or is it possibly because I'm casting these values to float, since I use this later for drawing... Rotating the cube has nothing to do with its size! … | |
Re: Tell me in psuedo code what each of these function below needs to do in order to achieve its purpose[code] void reverse(char unencrypted[], char encrypted[]); void flip(char unencrypted[], char encrypted[]); [/code] | |
Re: or you can just make your own function : [code] int round(float num){ return (int)(num+0.5); } int roundDown(float num){ return (int)(num); } [/code] example output : [code] Enter a number : 3.14 Round = 3 roundDown = 3 Enter a number : 3.5 Round = 4 roundDown = 3 [/code] … | |
Re: in your preprocessor add : using std::vector; Use the rand function in your library to place the battleship in random spot. Something like this : void placeRandomly(){ int x = rand()%MAP_SIZEX; int y = rand()%MAP_SIZEY; this.place(bigShip, x , y); } | |
Re: Look up the definition of a prime number, and you will see that it is a number that can only be divisible evenly by itself and 1. For example , 3 is a prime number because 3 can only be divided by its self(3) and 1, without having any remainder … | |
Re: Just to add, another way to prase string using sstream : [code] void praseString(string& src, float dst[], int size){ stringstream convert; convert << src; for(int i = 0; i < size; i++) convert >> dst[i]; } [/code] | |
Re: :-O >> goto P; Huh-oh, you don't know what you just did. | |
Re: >>WHAT IS WRONG WITH THIS CODE? 1) You do not use code tags 2) You haven't included the necessary library 3) I don't think you understand what the question is asking, so understand it before you write the program. I'll try to break the question down for you : [code] … | |
Re: Welcome, a few things : 1) When posting a question : 1_a) Make sure you research first 1_b) Ask question clearly 1_c) Use code tags 2) Try your best to write in a good grammatical way, and try not to use slang language, yo. MIT, huh? How is it there? … | |
Re: At this stage(I am assuming), it may be easier( for you) to create a function, like so : [code] class Timer { int h,m,s; public : void getTime() { cin >> h >> m >> s; } } [/code] | |
Re: Is this for a tradition pong game, where the paddle could only have 1 x coordinate and move only up or down? | |
Re: You need a conversion equation , look below as an example : [code] #include<iostream> using namespace std; int main(){ const int R = 4; const int C = 4; int A[R * C]; for(int i = 0; i < R*C; i++) A[i] = i; //print out as row and colum … | |
Re: ROTFL : Thank you :icon_smile: | |
Re: Hint, when you declare a function prototype inside a class, make sure it has the same signature outside of its class, that is when you define it. | |
Re: >>Would you recommend breaking the order string down? If so how? I guess if you really have to. Here is an example, breakString2 is just breakString1 using loops, see how much space is saved. Anyways, I provided both so you can understand what one function is doing : [code] #include<iostream> … | |
Re: The distance between two vector is given by (v1-v2).length(); Your return type should be similar to the parameters passed. And welcome! | |
Re: Neither. Its should look something like this : [code] ~LinkedList(){ List * temp = head; while(temp != null){ temp = temp->next; delete head; head = temp; } } [/code] | |
Re: >>Is it possible to have them all round out to only two decimal places? First you have to decide if : 1) You want to output up to 2 decimal 2) You want the actual value of the decimal to be 2 decimal places long. | |
Re: Try this : [code] double norms(double vectorA_xcomponent, double vectorA_ycomponent, double vectorA_zcomponent, double[COLOR="Red"]&[/COLOR] norm_1) { norm_1 = (vectorA_xcomponent+vectorA_ycomponent+vectorA_zcomponent); return norm_1; } [/code] Change the prototype as well. | |
Re: Sounds like H.W. Try googling it up, and read a couple articles and post what you think the answer should be, and from there we could determine if you got it( from our opinion) | |
Re: change float points (x1, x2, y1, y2) to float points (float x1, float x2, float y1, float y2) also your distance formula is wrong : distance = sqrt(x2-x1) + (y2-y1);[/code] the distance between two points is given by the formula : D = sqrt( (x2-x1)^2 + (y2-y1)^2 ) | |
Re: [code] * * * * * # # # 1 * * * * # # # # 2 ROW * * * # # # # # 3 [/code] realize that there are 5 '*' the 4 '*' then 3 '*' after each line. On the other side, there … | |
Re: Something like this : ? 1) Create a result list 2) Merge list A and list B 3) copy result list to list A, while making sure that list A has enough add at each insertion. | |
Re: Use sstream; [code] #include<sstream> #include<string> using namespace std; int main(){ stringstream converter; string str= "3.14"; converter << str ; //put in string float PI = 0; converter >> PI; //put out float return 0; } [/code] | |
Re: how about getting the input as string( or char array if you can't use string). [code] string num = ""; cin >> num; if( validate(num) == false ) //Error ... [/code] Validate function : [code] bool validate(string num) { if( num[0] < '0' || num[0] > '9') return false; return … | |
Re: Not exactly sure if this will help but the equation to a circle is : [code] //Cartesian coordinate X^2 + Y^2 = R^2 //polar coordinate //R = radius sin^2(x)* R + cos^2(X) * R = 1 [/code] | |
Re: where is the position of the box relative to ? Its center ? Edge ? |
The End.