Forum: C++ 18 Days Ago |
| Replies: 25 Views: 1,397 He just gave you the entire program and now you want comments (very nice program by the way, sfuo. It works well). Why don't you go through the code, figure out how it works, and after you do,... |
Forum: C++ 18 Days Ago |
| Replies: 25 Views: 1,397 I'm looking at the post times. This one comes two posts after firstPerson's post. Quite fast. I wouldn't "get it" either if I had to learn the Insertion Sort in two minutes. Since it uses an... |
Forum: C++ 18 Days Ago |
| Replies: 25 Views: 1,397 "Simple", "efficient", "correct", and "not tedious" are different concepts. Your "easiest", most brain-dead method is to make 120 "if" statements, not taking advantage of the results of previous... |
Forum: C++ 18 Days Ago |
| Replies: 25 Views: 1,397 Five numbers can be ordered 5! or 120 ways. The no-brainer way of writing this code would thus be writing an if statement with 119 "else if" statements, one for each possible ordering. You should... |
Forum: C++ 22 Days Ago |
| Replies: 3 Views: 278 Add this to your Header.cpp file:
List::~List()
{
}
or delete this line in Header.h: |
Forum: C++ 25 Days Ago |
| Replies: 8 Views: 378 Here's a skeleton that might help. It doesn't do any input validation and it doesn't correctly calculate the average. That will be up to you. But it gives a skeleton on how to pass the parameters.... |
Forum: C++ 25 Days Ago |
| Replies: 8 Views: 378 & signifies that the parameter is passed by reference, not passed by value. If this is a new concept to you, google "C++ pass by reference" and "C++ pass by value". Here's a link that explains and... |
Forum: C++ 25 Days Ago |
| Replies: 8 Views: 378 Please use code tags.
// code here
void getScore(double s1, double s2, double s3, double s4, double s5); |
Forum: C++ 27 Days Ago |
| Replies: 9 Views: 335 I don't get that error. I get a conversion warning that went away when I did this:
int t = (int) (ceil(sqrt(num)));
http://www.cplusplus.com/reference/clibrary/cmath/sqrt/
It might... |
Forum: C++ 27 Days Ago |
| Replies: 9 Views: 335 The formatting/indentation makes this code very hard to read. Compare with this:
#include<iostream>
#include<fstream>
#include<iomanip>
#include<string>
#include<cmath>
using namespace std; |
Forum: C++ 27 Days Ago |
| Replies: 9 Views: 335 The formatting/indentation makes this code very hard to read. Compare with this:
#include<iostream>
#include<fstream>
#include<iomanip>
#include<string>
#include<cmath>
using namespace std; |
Forum: C++ 27 Days Ago |
| Replies: 5 Views: 392 You're printing a bunch of spaces, then an endline. Don't do that. It's pointless to have the last character in a line be a space.
Here's what you need to do:
Display a certain number of... |
Forum: C++ 28 Days Ago |
| Replies: 9 Views: 335 Mathematically, any non-prime number will have a factor less than or equal to its square root. That means that if you have established that a number has no factor less than or equal to its square... |
Forum: C++ 30 Days Ago |
| Replies: 8 Views: 351 If you read it in as a c-style string, you can use getline and specify 6 characters (5 + 1) maximum. Or use get () five times.
http://www.cplusplus.com/reference/iostream/istream/getline/
... |
Forum: C++ 33 Days Ago |
| Replies: 13 Views: 489 If you can get it to work without a function, it's a matter of converting that code so that it's inside of a function. Post the code that works where it's all in main. |
Forum: C++ 33 Days Ago |
| Replies: 17 Views: 466 That's what "return" does. It takes you back to main, to the place right after where you called the medic function, which puts you back in the main function. So if the person enters 2 in the medic... |
Forum: C++ 33 Days Ago |
| Replies: 17 Views: 466 Do NOT call the main() function. If you want to repeat, your program should look something like this (starting at line 61):
do
{
// display user's options
// ask user to input option.
... |
Forum: C++ 33 Days Ago |
| Replies: 17 Views: 466 Lines 20, 88. Arrays already are passed by reference. Get rid of the ampersand:
void medic(int & money, int & potionsize[5]);
Delete the ampersand in red above on line 20 and on line 88.... |
Forum: C++ 33 Days Ago |
| Replies: 4 Views: 289 // outline
// #include statements here
// #define statements here
// global variables here
// function declarations here
int main (int argc, char* argv[])
{ |
Forum: C++ 33 Days Ago |
| Replies: 6 Views: 446 Looks good to me. Try it out. Does it work? |
Forum: C++ 33 Days Ago |
| Replies: 6 Views: 446 #include <iostream>
using namespace std;
int main()
{
int TESTS = 0;
int testScore[TESTS];
int testNum = 0;
int a;
double total = 0; |
Forum: C++ Oct 31st, 2009 |
| Replies: 13 Views: 489 You're simply merging two files that are ALREADY in order into one output file. Hence only very minimal storage is required (one value from each input file), so vectors are overkill. Have two... |
Forum: C++ Oct 30th, 2009 |
| Replies: 10 Views: 716 That's what I don't understand. Seeding seems necessary to me here. Isn't it necessary to seed the random number generator if you want good results? |
Forum: C++ Oct 30th, 2009 |
| Replies: 10 Views: 716 I'm intrigued. Why would you consider not seeding the RNG here? |
Forum: C++ Oct 28th, 2009 |
| Replies: 5 Views: 397 This is what I've been harping on since the major change-over at Daniweb. Java code is now flagged as C++ code instead of plain-old code if you don't specify Java-specific code tags. It... |
Forum: C++ Oct 23rd, 2009 |
| Replies: 4 Views: 359 Garbage in, garbage out. Before you spend a lot of time analyzing your functions to see where the logic error is in calculating the lowest, highest, and average, loop through your array and make... |
Forum: C++ Oct 23rd, 2009 |
| Replies: 4 Views: 398 Lines 14 and 16 - get rid of the semicolons. With the semicolons there, there is no loop.
Line 15 - it would be an error with the semicolons above, but after you take them out, notice that you... |
Forum: C++ Oct 21st, 2009 |
| Replies: 12 Views: 474 while (N>1 && i>=0)
{ fact = fact * (N-i);
i = i+1;
}
Yes, i changes, but not in a way that will get you out of this loop. N doesn't change, so this is an infinite loop. Once... |
Forum: C++ Oct 20th, 2009 |
| Replies: 3 Views: 240 Line 33 - number is not initialized and you are using number to initialize nuCoins, so you are initializing nuCoins, but you have no idea what you're initializing it to since number is not... |
Forum: C++ Oct 18th, 2009 |
| Replies: 4 Views: 245 I can't analyze the code you attached since it's in a language I don't know. But here's an example of a very simple encoding technique that simply pads to "encrypt" (not really encryption), and... |
Forum: C++ Oct 17th, 2009 |
| Replies: 5 Views: 378 infile >> value;
while (!infile.eof())
{
outfile << value;
outfile << endl;
infile >> value;
} |
Forum: C++ Oct 15th, 2009 |
| Replies: 4 Views: 255 Preview your post and correct the triangle before posting. Keep in mind that code tags post in Courier font, but when you type it in, it isn't. You should design it in a word processor in Courier... |
Forum: C++ Oct 14th, 2009 |
| Replies: 4 Views: 255 Please repost the expected and actual output in code tags. All spacing gets stripped out otherwise so we don't know if that happened here. I suspect so because neither figure looks like a diamond. ... |
Forum: C++ Oct 10th, 2009 |
| Replies: 6 Views: 497 I'm not a Windows programmer, so I can't help debug, but is there anything in the program that requires you to use all of these Windows-specific headers? Will the regular C and C++ standard... |
Forum: C++ Oct 10th, 2009 |
| Replies: 6 Views: 389 Post has nothing to do with the thread.
Original poster has shown no effort, so you shouldn't be fixing the code from another poster, even if you were posting on the correct thread, which, again,... |
Forum: C++ Oct 7th, 2009 |
| Replies: 21 Views: 693 Well, if "head" isn't supposed to be there, why did you put it there in the first place in line 43? |
Forum: C++ Oct 7th, 2009 |
| Replies: 4 Views: 211 Line 160 - the old = versus == typo. Make sure you don't have it anywhere else. |
Forum: C++ Oct 7th, 2009 |
| Replies: 4 Views: 211 You need to post more code. We need to see the declaration of mGPA. Presumably it's a double, float, long, int, something like that, so when you enter "x", >> can't do anything with it and it has... |
Forum: C++ Oct 6th, 2009 |
| Replies: 21 Views: 693 So "head" is supposed to be in there or not? Your output ends with dots after "Elizabeth". "head" is after "Elizabeth" in the alphabet, so the dots are ambiguous. If you have 50 names in the file,... |
Forum: C++ Oct 5th, 2009 |
| Replies: 21 Views: 693 newNode doesn't have a type, or at least if it does, it's not declared here. It's just some variable name. If its type is a pointer to nodType, you need to declare that:
nodeType* newNode = new... |