2,712 Posted Topics
Re: Hold shift front_slash. The frontslash is usually on top of the enter key. | |
Re: Ouch, your logic is bad. You are killing your program slowly. Luckily it fights back with the runtime exceptions. Can you comment line by line so I see what your thinking process is. That way you will learn better when you see whats wrong. | |
Re: You have this : "<< printMonth(x);" In most of your function. Take out the "<<" and let it just be printMonth(). | |
Re: no. the k is passed in from main. So k can be any number. For example, inside you main : [code] int main() { binomial(5, 10); // here k = 10; binomial(3, 276); // here k is 276 } [/code] | |
Re: >>denominator = 1*2*...*k I hope you know thats not valid. 1 * 2 * 3 ... k is called the factorial of K So if K was 5, the the denominator will be 1 * 2 * 3 * 4 * 5. So make a function : unsigned long factorial(unsigned … | |
Re: [QUOTE=donaldw;1066249]Modulo 10? eg: 54%10 = 4[/QUOTE] TO expand x % 100 will give you the last 2 digits, and x % 1000 will give you last 3 digits, and in general : x % 10^n will give you the last n digits. IN the special case where n = 0, … | |
Re: [QUOTE=Narue;1066145][B]>Does anyone have code out there on how to do this?[/B] Assuming this is homework, you don't really learn anything by stealing another programmer's code and palming it off as your own.[/QUOTE] Sure you do. You learn the intricate art of stealing programs and plagiarizing it, while feeling completely not … | |
Re: Can you use polar coordinate, or this equation of the circle ? [code] for theta = 0 to theta < 360 degrees; ++theta{ x = cos(theta) * radius y = sin(theta) * radius //center* is where the circle should be centered at drawAndFillPoint(x - centerX , y - centerY) } … | |
Re: You need to do a little more : [code] int LoadBitmap(const char* filename) { GLubyte* pixels; HBITMAP hbmp; BITMAP bmp; GLuint size; GLenum format; GLuint totalBytes; texID++; hbmp=(HBITMAP)LoadImage(GetModuleHandle(NULL), (LPWSTR)filename.c_str(), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE ); if(hbmp==NULL) { MessageBox(NULL,L"ERROR : CANNOT LOAD FILE!",L"IMAGE LOADING",MB_OK); return -1; } GetObject(hbmp,sizeof(bmp), &bmp); size … | |
Re: Or just return an array of strings, whichever one, both do the same job and depending on the context, one might be better to use than the other. | |
Re: When printing a binary tree you can either print it in pre, mid, or post order. I am not going to explain all of these. You should google them. The usual way one would display a binary tree is by either one of the printing methods from above, pre ,post … | |
Re: I suggest make a binary tree class and make the printing function. Add a few numbers. And print them out pre,post, and mid. Examine the output. Try to construct a binary tree from the output. You will then realize the pattern. | |
Re: [QUOTE=rrvs331;1065639]Can you give me an example, as to how to use this, because I want to set the range of numbers.[/QUOTE] [code] int main() { srand( time( 0 ) ); cout << rand() % 2 << endl; } [/code] | |
Re: You can do that or you can do what dkalita suggested. To expand on his suggestion : Say the input is "1001". To check if it is a palindrome you need to compare the first value + n, to the last value - n. Lets start : [code] // Input … | |
Re: Ouch. First off your code is not very readable. In fact there are statements in your code that you probably think is doing something else than it does. I think we need to take this step by step, for your sake and for my eyes. So what is your main … | |
Re: use [URL="http://www.cplusplus.com/reference/iostream/stringstream/stringstream/"] stringstream[/URL] | |
Re: Use strings and sstream. Get the input as strings. For example : [code] string input = ""; cout << "<enter text > :\t"; getline(cin,input); [/code] Then use sstream to extract words by words, using the space between them as delimiters. If you don't know about the sstream, read up on … | |
Re: Start out with the rock paper scissor games. I'll try to give you a psuedo code body. (Not saying its right though) [code] #include<iostream> using namespace std; //function prototype char getRandom(); //return random rock , paper , or scissors int main() { //create variables char playerPick= 0; char computerPick = … | |
Re: See if this works. Also since you are using string and cctype header, you should capitalize on their functions. I changed your functions a little bit : [code] #include <iostream> #include <string> #include <cctype> using namespace std; string pigLatin(string); bool isVowel(string); bool isCapital (char); bool isConsonant (string); string flipword (string); … | |
Re: [QUOTE=merse;1064936]String is an object, but it can be initialize without (), like [CODE]string str;[/CODE] However if I define a user defined object, I must initialize it like: [CODE]myclass myobj(); [/CODE] How is it possibel to not use: () ?[/QUOTE] The compiler will most likely mistake myobj as a function! As … | |
Re: [QUOTE=Narue;1064986][B]>I have no clue on how to do this please help thank you [/B] You'd better learn quickly how to deal with this situation without running to someone else for hand holding. The majority of the time, a programmer has no clue how to do something. That's why it's such … | |
Re: First make two variables, sentence1 and sentence2, unless you are using a period '.' as the end of one sentence. Use string if possible. All you need to do is capitalize sentence[0], the first letter. if its lower case then use the function from cctype, toupper(char). It returns the uppercased … | |
Re: Easiest way to do it is with [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/rand/"]the rand function[/URL] | |
Re: Not sure but here is a suggestiong. Look at the pixel where its way off the average , so if a camera lens is white , then its average should be close to white. If there is a dirt on the lens, then its pixel will be way of the … | |
Re: For bubble sort all you have to do is blindly swap : [code] int A[5] = {5,3,1,7}; //bubble sort for(int i = 0; i < 5; i++){ for(int j = i+1; j < 5; j++) if(A[i] > A[j] ) std::swap(A[i],A[j]); } [/code] | |
Re: Sure what part. There is a lot. You need to be more specific. Take it part by part. Do you need help with input and output, vectors, algorithms, what? | |
Re: An even easier way :[URL="http://www.cplusplus.com/reference/iostream/istream/tellg/"]Link[/URL] | |
Re: If your function parameters looks this this : [CODE]foo( Type a, Type b, Type c, Type d, Type e, Type f ...[/CODE] The that suggest that you either need to break up your functions into more small and compact and readable function or use OOP programming. | |
Re: since you are using vectors, and the vectors already contains data, then all you have to do is jumble up the data into different place. Therefore there is a function called std::random_shuffle that does just that. Here is the [URL="http://www.cplusplus.com/reference/algorithm/random_shuffle/"] link[/URL]. Unsurprisingly, they use vectors as an example. | |
Re: its not substr[i], its substr(i); Plus you are making this way to complicated. But before I suggest something, Are these assumptions correct : 1) You are comparing the student answer keys with the correct ones. 2) The student has answered all the question. 3) You need to count how many … | |
| |
[URL="http://thedailywtf.com/Articles/Vector_Oriented_Programming.aspx"]This is too hilarious.[/URL] | |
Re: I assume you call CheckTimer in a loop somewhere right? | |
Re: ??? [code] for(int i = 0; i !=1; ++i) cout << "M"<<endl; [/code] | |
Re: Use the mode (%) operator inside a for loop like so : [code] final int MAX = 100; for(int i = 1; i < MAX; ++i){ if(i % 2 == 0 ) /* if i is a multiple of 2 */ { //do stuff } else if(i % 3 == … | |
Re: Do you have a sample run? Is it something like this you think : [code] Enter n : 10 From [0,10] there are 11 different numbers. [/code] | |
Re: You put (Nov 28th 2009): [QUOTE=mGabriel;1061354]You put: <code snipped> Cya.[/QUOTE] He put ( Jul 16th, 2004 ): [quote] hi, this is the code for switch: include <stdio.h> <snipped> [/quote] See the problem? | |
Re: If you have a stack overflow then try to allocate on heap. Use smart pointers if you can. | |
Re: In all of your program you have never initialized the Size variable! I didn't know that the array has to be sorted from the number of occurrence, sorry. Edit : would you mind using something like map. It would be easy. Or actually using struct would be easy too. And … | |
Re: >>x^2 + 0.17714x -2.5147583 with k = 1.4997 What does the k represent ? Also for vectors you can just assign another vector by using the '=' assignment operator. If you want the reverse it, then use the std::reverse to reverse a vector then use the assignment operator, better practice. | |
Re: You don't have to manipulate the array after being sorted. You can use a for loop to start from 1 to the array size to show the array. This would disclude the last element. Of course you need to see a 0 at the beginning, so before the for loop … | |
Re: What you are doing is reading the first file and then reading the seconds file. Read both the files at the same time. | |
Re: Yes, use string. If not, then create a variable for the left side before t, then a variable for the right side after t. Then concate left and right to make a new c-string. | |
| |
Re: So you want to consider only the even row and column. The see if that even row or column is a even number, if so set it to 0 else do nothing? | |
I use netbeans but was wondering if anyone knew how to add a Java compiler to visual studio 2008? | |
Re: don't use the sqrt function. compare the squared distance. | |
Re: To use the copy command for a 2d vector, you would have to copy each row into the array, not efficient to make so many calls if a few for loops would do. |
The End.