2,712 Posted Topics
Re: Just to check, what happens when you comment out line 24? | |
Re: Usually my password, is something like this , xxxxxxYZZZZ, where x is a letter, Y is a punctuation, and Z is a number. | |
Re: clock() returns the time in mili seconds, CLOCKS_PER_SEC is the conversion factor from the value returned by clock() into seconds. [code]while (clock() < stopwait) {} [/code] That code waits until the value returned by clock() is greater than stopwait, meaning, it waits X amount of milliseconds, where x is stopwait. | |
Re: For powers of two all you have to do is use the shifter, which is very fast and is probably almost constants for the usual powers of 2. For ordinary numbers, its probably the O(exp), where exp is the exponent. For example, base^exp, to calculate that it would probably take … | |
Re: Maybe an easier class will help see below : [code] class Integer{ private: int myInt; //an integer variable public: Integer(){ myInt = 0; } //a constructor Integer(const int initValue){ myInt = initValue; } //another constructor void setMyInt(int value){ myInt = value; } //set myInt to some value int getMyInt(){ return … | |
Re: There is also [URL="http://www.eclipse.org/downloads/"]Eclipse[/URL]. | |
Re: The easy way is to use the setw method or the cout.width method. Take a look : [code] void printChars(const char whatToPrint, const size_t howMany){ for(int i = 0; i < howMany; ++i) cout << whatToPrint; } void printTri(const size_t height){ for(int i = 0; i < height; ++i){ std::cout.width(height-i); … | |
Re: Lets take test cases an see where that leads us. <input> 4 2 <output> 4/2 We need the output to show it in the reduced term so 4/2 reduces to 2/1 which reduces to 2. For the test case above name some things you notice about 4/2 ? | |
Re: Do you know what this means : [code] typedef unsigned int uInt //? [/code] Do you know what a class is? Then all this [code] typedef basic_string <char> string[/code] is, is a typedef for a template class called basic_string; Its the same as this : [code] typedef int INT [/code] … | |
Re: >>short shortEgyPop = 80000000 [CODE]for_each(seconds : 1 minute) printBig("OVERFLOW");[/CODE] [CODE] //From MSDN //"Microsoft Visual C++ recognizes the types shown in the table below." Type Name Bytes Other Names Range of Values short 2 short int, signed short int short -32,768 to 32,767 unsigned short 2 unsigned short int 0 to … | |
Re: [QUOTE=magdalin;1119667]i want the time complexity for transpose of a matrix i want the time complexity for heap sort i want time complexity for merge sort[/QUOTE] And I want : 1) 1 million dollars 2) 2 billion dollars 3) 3 trillion dollars I got an idea, how about you help me … | |
Re: Haven't looked at it in details, but I see that your search function is a linear search. Make it a binary search since the array should be sorted already. You will see that using the linear search you will have to do about on average N/2, where N is the … | |
Re: Pause it. [code] if (lower_first > upper_first) { printf("Lower-bound IP address > upper-bound IP address"); cin.get(); exit(0); } [/code] | |
Re: This is wrong : [code]T min(vector<T> a())[/code] Try to guess which part. Edit : Hint look at the error | |
Re: No its not valid. And thats because of the operator precedence. Here is an example that shows how to make it valid : [code] class Int{ public : int var; Int() { var = 0; } Int(const int& i) { var = i; } }; int main(){ Int * num … | |
Re: A class : [code] class Test{}; [/code] A pointer : [code] int *p = 0; [/code] Combine them and you get a "class pointer" : [code] class Test{}; Test *p = 0; [/code] | |
Re: You need to make it a reference. In fact do something like this : [code] void write(const string& str, std::ostream& out = cout){ out << str << endl; } [/code] Now you can call the code like this : [code] write("Hello"); // and prints to screen write("Hello",myout); //and write to … | |
Re: You might be looking for constructor with default value : [code] struct Int{ int var; Int(const int& initValue = 0) { var = initValue; } }; [/code] Therefore when you do this : [code] Int num = Int(); //num = 0 for now Int num2 = Int(2); // num = … | |
Re: When using list, you have to use iterators. When using vectors you have a choice of using index or iterators, usually you should pick the index version( which means use the operator [] ). The STL uses iterators to generalize their functions. For example using std::sort(..), it takes in a … | |
Re: Oh when you say pair you mean in an 2d array like structure? Like so : [code] Random generate= new Random(); int[][] Array2d = new int[4][4]; for (int row = 0; row < Array2d.length; row++){ for (int col = 0; col < Array2d[row].length; col++){ Array2d[row][col] = generate.nextInt(8) + 1; // … | |
Re: [QUOTE=dude1;1117241]i have a numeric updown that goes from 0-99 and it works but i want to make it continuous so if i hit the down when its at 0 it goes to 99 and when its on 99 and i hit up it goes to zero anyone know the code … | |
Re: Here are some hints : For the divelement function you need to see if a number is multiple by 5? One way to do this is to use the mod operator. The mod operator returns the remainder. Here is an example on how to use it : [code] //returns true … | |
Re: [QUOTE=Salem;1107281]Only this time, it wasn't. My reply to [URL="http://www.daniweb.com/forums/thread254052.html"]this thread[/URL] is there in the singular. But I also got a "This forum requires that you wait 15 seconds between posts. Please try again in 1 seconds." I rather suspect had it timed out differently, it would have been a double … | |
Re: combine your even and odd in one loop : [code] for(int num = start; num != end; ++num){ if(num % 2 == 0) cout << num << " is even\n"; else cout << num << "is odd\n"; } [/code] | |
Re: I am not sure whats your problem? Do you want to generate random character, if so then use something like this : [code] //returns a "random" letter char getRandomChar(){ return rand() % ('z' - 'a') + 'a' } [/code] | |
Re: Your code is really hard to look at. But from your question : "cant determine the winner" I figure that the winner checker is not working. There are 2 things you can do. Option1 : Make a hard-coded function that checks for winner Option2 : create a for loop to … | |
Re: >>[B] i am not dating but once you are into something real, you dont feel like you need females any more..[/B] Sounds more If a hot girl hit on me, then I would be dating, but since I do not have the courage to hit on hot girls, I found … | |
Re: I have commented on your code with code comments , see below : [code] #include<iostream> using namespace std; [COLOR="red"]// A TEMPLATE CLASS WILL BE BETTER[/COLOR] class matrix[COLOR="Red"] //USUALLY A CLASS NAME SHOULD START WITH A CAPITAL LETTER( from convention)[/COLOR] { [COLOR="Red"] //is the user able to change these ? if … | |
Re: This code causes a memory leak. [code] IntSLLNode *tmp; tmp = (IntSLLNode*)malloc(sizeof(IntSLLNode)); tmp = head; [/code] So does this code : [code] IntSLLNode *oldTmp; oldTmp = (IntSLLNode*)malloc(sizeof(IntSLLNode)); oldTmp = tmp; [/code] | |
Re: Or just create a function that converts to necessary data-types. | |
Re: Why do you need pointers? Now just do something with the gauss function, like so : [code] double gauss(fun f, double a, double b, int n){ return ( (*f)(a) + (*f)(b) ) * n; } [/code] The above is just a random example. | |
Re: [QUOTE=zero_crack87;1112977]i want diz for my final project...tq[/QUOTE] Really? I mean really ? I am utterly speechless. Really, you have got to be kidding? | |
Re: *sigh*, Another post without code-tags. If only I had $1000 for every post without code-tags. You should be using arrays to get the input first, instead of the ugly hard-coding, and use std::strings like so : [code] const int MAX_INPUT = 10; string userInputs[MAX_INPUT] = { string(""); } for (pos … | |
Re: [QUOTE=kriszy0515;1112500]hello??? can you give me a complete program about a fraction calculator???[/QUOTE] I'll give it to you for 1 zillion gazillion quintillion dollars? | |
Re: When posting code, the format should look something like this( see below), if it isn't then make it until it is. This is not only help us read better, but it will also help you get better comments. [code] //notice not .h #include <iostream> #include <cmath> using namespace std; int … | |
Re: All you have to do is read the file but insert the elements you get into its correct place. Is this enough of a hint? | |
Re: [QUOTE=GrimJack;1105422]I'm a jerk[/QUOTE] Then here is your theme [URL="http://www.youtube.com/watch?v=qv9VKKXwVxU&feature=related"] song.[/URL] I am the worlds champion at [URL="http://en.wikipedia.org/wiki/Human_hunting"] this [/URL] sport. | |
Re: They are the member variables. For example : [code] class Person{ private: //attributes int health; int power; public: Person(){ ... }; } [/code] So a health and strength is an attribute of a person. | |
Re: Is this what you need : [code] #include <iostream> #include <string> #include <sstream> using namespace std; typedef size_t Type; string toHex(const Type& number){ stringstream stream; stream << hex << number; return stream.str(); } int main(int argc, char *argv[]) { string num = toHex(15); cout << num << endl; return 0; … | |
Re: Damn as soon as I graduate college, I will be dead. I guess I should drop out. | |
Re: First declare a function like so : [code] int readInt(std::ifstream& readFile){ int res = 0; //error checking if you want readFile >> res; return res; } [/code] Then you can make another function that loops that function like so : [code] void readIntArray(std::ifstream& readFile, int *Array, const int Size){ int … | |
Re: >> I'm trying to copy a value in a vector to a string. The vector is also of string type, I'm trying to copy through the iterator So you are trying to copy the strings inside a vector into an array ? or into another vector ? or into another … | |
Re: [QUOTE=jonsca;1109569]Unfortunately you don't show us the add() method itself. Does it make sure that the last pointer is not null? Does it create a head at the beginning if there's not one?[/QUOTE] He shows it at the beginning : [code] void LinkedList::add(string imissjava) { temp = (node*)malloc(sizeof(node)); temp->data = imissjava; … | |
Re: Thats not going to be very easy for a beginner. What part do you need help with? Also is the function for (2) correct? Is that column's law. | |
Re: compare your program to this( not compiled ) [code] #include <fstream> #include <iostream> #include <string> using namespace std; int main() { ifstream file("Ahoo.txt"); if(!file) return -1; string wordToFind; cout <<" Enter a word to find in the file Ahoo.txt\n"; cin >> wordToFind; string word; bool isFound = false; while( file … | |
Re: Your code is asking for trouble. You need to seed the random generator, put this code inside the main where it will be called only once, : [code] srand( time(0) ); [/code] | |
Re: >>srand(unsigned(time(NULL))); You only need to do this once. Put that statement inside main, and just call it once. It only needs to be called once. | |
Re: Usually C++ test are useless. A test just shows that you know definition( in a sense). It does not really show how well you program. Instead of looking for a test, how about you program a big project, with big being subjective. Learn a new skill. Do you know anything … | |
Re: You mean something like this : [code] bool find2D(int Array[][COL],const int key, const int MaxRow){ bool isFound = false; for(int row = 0; row != MaxRow; ++row){ if( findArray(Array[row], COL, key){ isFound = true; break; } } return isFound; } [/code] |
The End.