- Upvotes Received
- 3
- Posts with Upvotes
- 3
- Upvoting Members
- 3
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
11 Posted Topics
Re: for that matter I'm pretty sure that the following is valid code: [CODE]int theMostAwesomestIntEver;[/CODE] | |
Re: Here's how I would go about it... [CODE] string word1 = "orchestra", word2 = "carthorse"; set<char> s; for(int i = 0; i < word1.size(); i++){ s.insert(word1[i]); } bool isAnagram = true; for(int i = 0; i < word2.size() && isAnagram; i++){ if(s.find(word2[i]) == s.end()) isAnagram = false; } [/CODE] The … | |
Re: It depends. There is no one best way to initialize a vector and the method you choose should fit the problem at hand. However, if efficiency is something which you want to place priority on, you should consider some of the other container types that are available. A vector uses … | |
Re: Honestly I can't spend the time to find the exact error(s). Hopefully someone else can help you with that. But maybe a couple pointers could be helpful (no pun intended). As great as pointers are, they are really risky. The more pointers you use the greater the chances are for … | |
Re: This is an aweful lot of code for someone to read through looking for who knows what. You might get better responses if you narrow down the problem a bit and ask specific questions. | |
Re: What you're dealing with here is a scope issue. An if block won't return anything in the sense that that a function would. If you want to retain a value determined within the block, you need to declare the variable which stores that value outside of it. | |
Re: The code seems to work fine, except for the part where the list destructor is missing its implementation. | |
Re: On line 25, the three variables are set to 1, 1, and 2 because these are the first three numbers in a fibonacci sequence (not including zero). Roughly translated, line 30 would read: "initially set n to n - 3, then decrement n by one and execute some code so … | |
Re: Sorry but the formatting just makes that horribly difficult to read. I did notice though that within your first loop you set compute = 'Y' instead of a comparison resulting in a boolean which should read compute == 'Y'. I hope that helps | |
Re: What is the problem? | |
Is there a way in C++ to handle unexpected errors? Other languanges I have learned tend to allow this but for some reason I cannot get the try/catch solution to work in all cases. Take the following example: [CODE] int main(){ vector<int> v; try{ //next line should cause an assertion … |
The End.