Forum: C++ 13 Hours Ago |
| Replies: 1 Views: 121 Matrix2d<int> mat;
aMat.sizeMatrix2d(xA, yA)
Line one above does indeed call your default instructor. In your default constructor you initialize rows and cols to zero and matrix to NULL. There... |
Forum: C++ 14 Hours Ago |
| Replies: 2 Views: 116 try declaring an empty STL style string. The concatenated each char to the end of the string. Store each string in an array and sort the array after input stops. |
Forum: C++ 1 Day Ago |
| Replies: 1 Views: 109 Always start with a plan on paper that you write out with pen/pencil. For example, in this case you might try something like this:
Determine mazeHeight
Determine mazeWidth
Use an array of type... |
Forum: C++ 1 Day Ago |
| Replies: 12 Views: 296 What definition of leap year are you going to use. the simple one is any year evenly divisible by 4, but there are more sophisticated, and accurate, definitions as well.
On the other hand,... |
Forum: C++ 2 Days Ago |
| Replies: 5 Views: 258 Nah, you don't want to start j at degree either. Must be getting tired, sorry. All right, so try something this.
//assuming p.coefficient contains all coeffients, even if the coefficient is zero.... |
Forum: C++ 2 Days Ago |
| Replies: 5 Views: 258 Tweak it a bit. Try putting a break; after finding the first remaining nonzero coefficient to prevent the multiple + signs and changing the starting point for j.
for(int j = degree - 1; j > 0; --j)... |
Forum: C++ 2 Days Ago |
| Replies: 5 Views: 258 >>poly.cpp(146): error C2679: binary '*' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
You could create a constructor that takes an int... |
Forum: C++ 2 Days Ago |
| Replies: 5 Views: 258 Try this:
//if any of the remaining coefficients is more than zero, then print out "+"
for(int j = n-1; j > 0; --j)
if(p.coefficient[j] > 0)
cout << "+";
Assuming degree is... |
Forum: C++ 2 Days Ago |
| Replies: 1 Views: 256 line 0 has 1 star
line 1 has 3 stars
line 2 has 5 stars
line 3 has 7 stars
Without looking at the program how many stars does line 4 have? How many stars, call that number y, would line x have? ... |
Forum: C++ 2 Days Ago |
| Replies: 12 Views: 296 Pretty straightforward for something like this:
struct
{
int day;
int month;
int year;
};
However, if you don't know the syntax for using that, maybe you better stick with six... |
Forum: C++ 2 Days Ago |
| Replies: 12 Views: 296 You've entered the year, but not the day or the month. You'll need that information, too. That means you'll need 6 variables to do the calculation. They can all be independent variables, or you... |
Forum: C++ 2 Days Ago |
| Replies: 4 Views: 242 >>i want this program to find a name after i enter it. here r the names that i want to put into names.dat.
Alternatively, create a section of your program to write whatever information you want to... |
Forum: C++ 2 Days Ago |
| Replies: 3 Views: 241 If you want to get the most "reuse" possible out of the struct you could put it in a header file by itself coupling it with an empty cpp file with the same name as the header file, but since the... |
Forum: C++ 4 Days Ago |
| Replies: 27 Views: 523 The math is square foot per room times 1 gallon of paint per 500 square feet. Then round that up to next int, which represents the number of gallons of paint to buy. Then multiply that int by cost... |
Forum: C++ 6 Days Ago |
| Replies: 4 Views: 436 Put it back where you found it then and start writing your own code. I suspect you can do better than what you found. One basic protocol to finding out if a number is prime is as follows:
int... |
Forum: C++ 6 Days Ago |
| Replies: 1 Views: 439 Welcome to the board. Please read about using code tags when posting code to this board so that you syntax formatting is maintained. The information you need is in both the announcement section and... |
Forum: C++ 6 Days Ago |
| Replies: 4 Views: 436 If you wrote it presumably you know what's going on, or what you want to have happen, and might not be. If you have a specific question post it. As it stands there is plenty of questions you could... |
Forum: C++ 6 Days Ago |
| Replies: 9 Views: 505 >>I'm trying to increase the size of the array
I'm confused with all the len, length(), pos stuff.
Basically if array a is too small and you want to enlarge it, then you can copy the contents... |
Forum: C++ 7 Days Ago |
| Replies: 5 Views: 667 It's shorthand to stand for a 2 dimensional array. It would mean something like:
char win(char board[3][3]) |
Forum: C++ 7 Days Ago |
| Replies: 5 Views: 667 in main
{
create board and intialize to E
declare plays and initialize to 1
declare no Winner and initialze to true
while(plays < 9 && no Winner)
{
make play
++plays
... |
Forum: C++ 7 Days Ago |
| Replies: 1 Views: 471 It is certainly possible, but the specifics of how to do it depend on how the file is set up. You need to know exactly how the file is set up and exactly what you want to do with the information you... |
Forum: C++ 7 Days Ago |
| Replies: 4 Views: 574 Change the extraction function to take a reference to an int as an argument and return an int. Extract just the least significant digit from the number passed and return it to the calling function... |
Forum: C++ 7 Days Ago |
| Replies: 7 Views: 247 You could always post the function used to delete the database so we could look at it.
Why do you load the database for each choice and save it to file everytime you change the data? Unless... |
Forum: C++ 7 Days Ago |
| Replies: 10 Views: 334 >>one person i talked to mentioned read the file as strings and tokenize the data is this a good way to do it?
If the file is ordered as posted it wouldn't be that hard to create a class modeled... |
Forum: C++ 9 Days Ago |
| Replies: 2 Views: 150 Move line 32 to between line 14 and 15. Only call srand() once per program. Call srand() before any calls to rand(). Declare the variable answer in main() and pass it to thinkUpNumber() by rerence... |
Forum: C++ 9 Days Ago |
| Replies: 4 Views: 187 int nums;
cout << "How many numbers do you want to enter?: ";
cin >> nums;
cout << "Enter " << nums << "numbers:";
for(int count = 0; count < nums; ++count)
{
cout << "enter number # " <<... |
Forum: C++ 11 Days Ago |
| Replies: 7 Views: 256 An int sounds fine.
You might consider declaring a function to randomly select an int between 0-6 and passing it the array of players (as per StuXYZ) they can eliminate and have the return value... |
Forum: C++ 11 Days Ago |
| Replies: 1 Views: 133 Welcome to the board and thanks for using code tags!
In order for the value of toty in main() to retain the change done to it in drawmore(), you need to send it to drawmore() by reference instead... |
Forum: C++ 11 Days Ago |
| Replies: 3 Views: 184 First welcome to the board and using code tags on your first post!
void arrays::Talk(hold&, keep&)
The correct syntax would be:
void arrays::Talk(string& hold, int& keep)
However, since... |
Forum: C++ 12 Days Ago |
| Replies: 14 Views: 317 for(int i=2; i <= 100; i++)
{
bool isPrime = true;
// Check to see if i is prime, print i out if it is.
for(int j=2; j <= sqrt((double) i); j++)
{
if(i % j == 0)... |
Forum: C++ 12 Days Ago |
| Replies: 10 Views: 443 As per your first post, now find the min and the max value of the array and display the values to the screen so you can prove you have the correct value. |
Forum: C++ 12 Days Ago |
| Replies: 6 Views: 232 Not sure where the H came from in the expected output since neither vector originally had an H in it, but that was probably a typo.
//check if elements of v1 are in v2
bool found = false;... |
Forum: C++ 12 Days Ago |
| Replies: 6 Views: 232 1) In my version I'd use a third vector to hold the results which eleminates to erase from either of the two source vectors, but you can do it as you please. Are duplicates allowed in either of the... |
Forum: C++ 13 Days Ago |
| Replies: 5 Views: 202 This:
Asteroid::Asteroid(const Asteroid &)
looks like it is refering to a copy constructor, which you don't include in your class. (The compiler will supply one for you, which may be okay in... |
Forum: C++ 13 Days Ago |
| Replies: 5 Views: 202 Doesn't relate to error messages, but:
void setSize( int astSize);
void setSpeed(int astSpeed);
int setSpeed()
{
return astSpeed;
}
int setSize() |
Forum: C++ 14 Days Ago |
| Replies: 2 Views: 189 Start by defining what a perfect number is. Is a perfect number one that equals the sum of it's factors other than itself? If so, then determine all the factors of the number, arrange them in... |
Forum: C++ 14 Days Ago |
| Replies: 21 Views: 517 A formula for calculating the number of employees needed is found. You can use it instead of a series of if/else statements to determine how many empolyees are needed.
number of employees... |
Forum: C++ 14 Days Ago |
| Replies: 14 Views: 397 There is much more information, for example what options does the user have, what instructions are desired, etc, needed before I could do anything vaguely resembling your request. In general it... |
Forum: C++ 14 Days Ago |
| Replies: 21 Views: 517 If the number of customers per hour is held in an array, fine. That information can be used to control how many times the loop I described above is run and you don't need to ask for user input each... |
Forum: C++ 14 Days Ago |
| Replies: 21 Views: 517 I suppose you could jury rig the program to use an array, but it isn't really necessary. It is most easily accomplished by using a sequence of if/else statements:
if the number of customesrs is 0... |