2,712 Posted Topics
Re: 1) Seed random number 2) use rand()/RAND_MAX * (max-min) + min; | |
Re: [QUOTE=Narue;961959][B]>So if you did mean well.. and even if it came out in a bent, skewed >and poorly communicated way, well thank you I do actually appreciate that.[/B] Too little, too late, and wording it like your misunderstanding is [I]my[/I] fault. It's a wonder you have any friends at all. … | |
Re: I think what you are looking for is something like this : [code] char *twoDee[][3] = {{"item1", "1", "1"}, {"item2", "1", "2"}}; [/code] You need to supply the column before hand. Thus the code : [code] char *p[][] = {{"item1", "1", "1"}, {"item2", "1", "2"}}; [/code] Is an error because … | |
Re: The AI should do something like this : 1) Check if you can move if the middle 2) Check if you can win in 1 move 3) Check if player can win in 1 move 4) Check if opposite corners from user is available 5) Check if any move is … | |
Re: "im facing the problem on how to use the ctime random,for loop and array " Seems more like your having problems using Google, let me help [URL="http://www.google.com/"]YOU[/URL] | |
Re: Look around and observe. They are everywhere. Trees, board, water, foods, wall, most of which seems to look like fractals. | |
Re: Your cin.get doesn't work because it read the newline character. use another cin.get(). | |
Re: cin does not read white spaces. use cin.getLine(...), or cin.get(...) or getline(...); They don't skip spaces. | |
Re: how about a pure virtual destructor. Also [URL="http://www.gotw.ca/gotw/031.htm"]gotW[/URL] | |
Re: [QUOTE=Ancient Dragon;488140] printf() beats the pants off cout every time. [/QUOTE] In what, user-friendliness? cout and cin are much more safer than printf. Most of the time cout is easier to format than printf; In my opinion of course. I see that you are a c guy? | |
Re: Hint1 : use a for loop. Hint2 : if your up to it, use recursion. Hint3 : Google oggle it | |
Re: [QUOTE=almasari;962419]come on. i want find the answer[/QUOTE] The answer is within you my child. Just unleash it! | |
Re: if(condition) { do this } else if(another condition) { do this } else if(another condition) { do this } else { do default } | |
Re: 1) Unless your compiler supports the keyword [I]export[/I], you have to provided the template header and its definition in the same file 2) Here is a example : [code] #include <iostream> #include <ctime> using namespace std; template<typename Type> class Example { private: Type var; public: Example(Type T); //see definition below … | |
Re: Also, from experience. I see that using 2D array to store information from a file does not always work well. The program might not set the file content it to proper location. I would suggest to use 1D array. If 2D is really needed , then use 1D array, and … | |
Re: I am a little confused about your question. What are you trying to do again? | |
Re: don't know or don't care on why you are reading the same file twice, if i understand correctly, but to answer your question, reset the file pointer to the beginning after reaching the eof(), by using similar to this code : [code] ifstream inputFile("toBeOrNot2Be.doc"); inputFile.seekg(0,std::ios_base::beg); [/code] | |
Re: Haven' you tried something? Give some idea you might have on how to go about this. | |
Re: Perhaps use windows.h if your OS is windows. [code] #include<iostream> #include<windows.h> using std::cout; using std::cin; using std::endl; int main() { _SYSTEMTIME st; GetSystemTime(&st); cout<<st.wMonth<< "\\" << st.wDay <<"\\" << st.wYear<<endl; } [/code] or [URL="http://www.cplusplus.com/reference/clibrary/ctime/mktime/"]google[/URL] | |
Re: 1) sort the data 2) count frequency of each data 3) find max number of frequency 4) return that number or index to that number | |
Re: Use [URL="http://www.cplusplus.com/reference/stl/list/begin/"]iterator[/URL] provided by list. | |
Re: Compare and contrast (sorting wise) : [code] #include<iostream> #include<vector> #include<ctime> //for time.h #include<algorithm> using namespace std; struct Info { int id; char gender; Info() : id(0) , gender(' ') { } Info(int i, char g) :id(i), gender(g) { } }; bool sortByID(const Info& a, const Info& b) { return ( … | |
Re: You know we can't see your code, so I can't help you. | |
Re: change to [code] void enterPurchase(float pur[][25], float nWeek, float counter); [/code] | |
Re: Although inefficient I will suggest you a way. [code] void rot(int *a, int sz) { int * t = new int[sz]; t[0] = a[sz-1]; for(int i = 1; i < sz; i++) t[i] = a[i-1]; for(int i = 0; i < sz; i++) a[i] = t[i]; delete [] t; } … | |
Re: [code] cin >> hex; //set the input stream to read in hexadecimal long num = 0; cin >> num; //input a number, example 15 cout<<hex<<showbase; // shows output as 0xsomeNumber cout << num; //prints 0xf instead of 15 [/code] you can do the same with ifstream iFile("number.txt") or ofstream oFile("numbers.txt"); … | |
Re: your function prototype is declared like so : [code] //accepts 2 string not 1 or 3. int name(string a, string name1); [/code] [code] cout<<"And what is yours?"; getline(cin,name2); name(name2); //you call it with 1 paramter, or 1 string [/code] Look below : [code] string name1 = "jack"; string name2 = … | |
Re: You could just use glPush/Pop Matrix. Makes it much easier. 1) draw sun say at (0,0,0) 2) draw earth at the same position as the sun 3) Translate earth to some radius 4) Now using glRotate on the earth would rotate the earth around the sun. 5) use glPushMatrix() /** … | |
Re: I'm sorry but I don't know where to begin. Your program needs indentation, and spaces. Its unclear. It uses system commands. Its uses goto commands all over the place. you allocate 900000000+1 memory twice and never delete it. Your encrypt and decrypt program is way out of hand. Your program … | |
Re: The compiler complains because you need to initialize const int a. Const variable are static binded by computer, so you cannot change its value during runtime. If the above code was allowed then you would be able to const variables during runtime. And this would violate const data variable's purpose, … | |
Re: Here is a sample app via openGL. [URL="http://rapidshare.com/files/259197210/Land_.zip.html"]Terrian[/URL] 1) Press ',' the comma key to get a outline view. 2) Press space bar about 15 times or so, to displace the land. 3) press 'c' to smooth out the land. Its one of my earlier project. | |
Re: There is a std::sort, and std::unique function. That should solve your problem. std::sort -- sorts data, std::unique -- removes duplicates from a sorted data. | |
Re: look at this [URL="http://www.asciitable.com/"]Table[/URL] and you will see that each '0' through '9' has a value in numerical standpoint. | |
Re: You might want to change some part of the student to accommodate strings. For example, a name should be a std::string instead of a char. [code] struct student { int ID; char name; char nationality; char gender; }; [/code] To use the keyword delete, for your array, you have to … | |
Re: Pick 1) I) [code]std::cout<<hex;[/code] II)[code]hex(cout);[/code] III)[code]cout.setf(ios_base::hex,ios_base::basefield);[/code] All these shows the output in hex. So no calculation needed. | |
Re: Just an idea, check the window size with glutGet and if its not what you want then resize it. | |
Re: If you want 3d the glOrtho is the wrong choice. glOrtho is for 2d. Use gluPerspective(45.0,width/(float)height,1.0,1000.0f); for 3d your reshape functions should look something like this : [code] void reshape (int w, int h) { if( !h) h = 1; glViewport(0,0,w,h); glMatrixMode (GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0, //angle (float)width/height, //ratio 0.001f, //znear … | |
Re: [quote]"mobile+pond==a"[/quote] What you are doing is comparing with the '==' bool operator. What you are saying with this statement is : Is mobile plus pond equal to a? If so say true else say false. What you want to do is use the assignment operator '='. Setting a = mobile … | |
Re: Look up ray casting for the mouse click and shoot. Basically what you need to do is have a line defined from the mouse click point to the player position vector. Then you have a line from the player to the spot where you clicked with your mouse. Now you … | |
Re: [QUOTE=Dave Sinkula;958455]Consider separating the 1's and 0's with whitespace. Otherwise, you may need to read each character as a char and convert to its equivalent digit.[/QUOTE] the file contains 3 lines of 1,000 integers. That will be a waste of time if you want to separate each int with white … | |
Re: Proper indent! [code] #include<stdio.h> #include<stdlib.h> #include<conio.h> #include<string.h> void main() { FILE *fp,*ft; char another,choice; struct emp; { char name[40]; int age; float bs; }; struct emp e; char empname[40]; long int recsize; fp=fopen("EMP.DAT","rb+"); if(fp==NULL) { fp=fopen("EMP.DAT","wb+"); if(fp==NULL) { puts("cannot open file"); exit(1); } } recsize=sizeof(&e); while(1) { clrscr(); gotoxy(30,10); printf("1.Add … | |
Re: To be a expert programmer rating 10 out of 10, you have to be born to program. But fortunately, there is 9.99. To achieve that rating from range 1 - 10, you have to study and work hard like everything else in this world. One thing I will tell you … | |
Re: Here is a recursion version. Try to make it non-recursion. [code] //row is the number of rows //itr is the number of column (sort of) void prnt(int row = 5,int itr = 1) { if(itr >= row) return; for(int i = 0; i < itr ; i++) cout<<(i+1); cout<<endl; prnt(row,itr+1); … | |
Re: Basic encryption, i.e weak but encrypted. 1) Read file content into string 2) Have a key number, say 5. 3) Shift all letter in the string by adding the key number [code] for(int i =0; i < string.size(); i+=) string[i] +=key_number [/code] 4) Now its encrypted. 5) For decryption, just … | |
Re: If you didn't realize this code : [code] int numX; int numY; int numZ; int sum1 = numX - numZ; int sum2 = numX - numY + numZ; int sum3 = numX + numY; int sum4 = numX + numY + numZ; int sum5 = numX; int sum6 = numX … | |
Re: Here are some problems. Easy to harder from my stand point. 1) hello world 2) Advance calculator 3) RPG game 4) your own string class 5) your array class 6) single linked list 7) array class using linked list 8) double linked list 9) Praiser 10) ...out of ideas [U]Printing … | |
Re: Divide and conquer. Think about those words. When trying to create algorithm, I) you will get better as you gain more experience. II) Think about the algorithm in parts. What do you need to happen first. Then go step by step. Its a simple step but its really powerful. IV) … | |
Re: another example : [code] typedef float data_type; data_type mySumRecursive(vector<data_type> vec, data_type * s,int strt = 0) { if(strt == vec.size()) return vec[strt-1]; *s += vec[strt]; mySumRecursive(vec,s,strt+1); } [/code] | |
Re: [quote]"finding parts of files."[/quote] No, not finding parts of the file but read the whole file, while analyzing it in the process. Assuming the file is the something like this : Info.txt --------------------------------------------- Password = hello_world Active t = false --------------------------------------------- 1) open up a file with fstream 2) read … |
The End.