1,608 Posted Topics

Member Avatar for crioto

Do a routine swap manually or use the swap() method from STL algorithm header file. The routine swap involves identifying the two items you want to swap, declaring a third item of desired type and doing this: temp = B; B = A; A = temp; Be sure your struct …

Member Avatar for crioto
0
93
Member Avatar for danishamman

Here's some answers, each with a grain of truth, but none of which I suspect your instructor is expecting. To find the real answers I recommend you search through your notes, your book, or, if you must, search the web. Q.no.1: What is the difference between zero and null values? …

Member Avatar for siddhant3s
0
155
Member Avatar for golden3159

If the last row has zero spaces to the left of the *s then somehow you have to get K equal to zero. row number zero has 1 * row number one has 3 *s row number two has 5 *s row number x has (2 times the row number) …

Member Avatar for Lerner
0
96
Member Avatar for MoOou

Do you have a problem with the math involved or the C++ involved? The easiest way to do the math you need using C++ is to use the modulo operator. Assuming m and n are both postive integers, if the result of m % n is zero then, n is …

Member Avatar for Lerner
0
291
Member Avatar for jagsrocknfl

Here's one approach: add an attribute called degree to linkedList class. It will be equal to the number of terms in the linked list. All terms will be listed in linkedList, even if coefficient (aka value) is zero. add a friend function to linkedList class to overload the + operator …

Member Avatar for Lerner
0
2K
Member Avatar for ganmo

Why would Node have an insert method? The insert method declared doesn't insert anything anywhere. It just declares a new Node, which seems dubious. Move the insert function to Set itself. Basically you can make the Set class a modified List class (or a wrapper around a List class), but …

Member Avatar for Lerner
0
133
Member Avatar for ARYT

In math: M(i,j) = ( k = 1 to n ) Σ { A (i,k) x B (k,j) } In C++: There are 8 variables to deal with: M, A, and B are matrixes (multidimensional arrays in C++ speak) rows is the number of rows in M and the number …

Member Avatar for GreenDay2001
0
525
Member Avatar for coder101

Conditionals and loops will probably be important to your program, as they are in just about any program. Remember that if the response is more than one character long that isn't a digit, then you have to use a string variable (there are several versions of string variables you could …

Member Avatar for WaltP
0
168
Member Avatar for monocog

You are welcome to do what you want with your compiler and you machine. You should be aware however that there is a jargon associated programming in C++ just like there is in most other areas of life. One of the traditional assumptions (jargon) when talking about lists in C++ …

Member Avatar for Lerner
0
95
Member Avatar for beddy085

Do you have a class to represent a card? Does the class have the ability to distinguish when one card is bigger/lower than another? What are the rules of the game? Is it more like "War" or more like "Rock, Paper, Scissors"?

Member Avatar for dawsonhowe
0
192
Member Avatar for songweaver

play around with the value of n and see what happens. In particular, try changing n from 1 to 2 to 3 etc. The function as written isn't specific for rounding to 2 decimal places. Also, look into the stream manipulators, and here I'm thinking of the fixed and setprecision …

Member Avatar for songweaver
0
1K
Member Avatar for ixuz
Member Avatar for lancevo3

Be sure the sum variable is initialized to zero before you try adding to it. Otherwise looks pretty good. I'd probably do something like this[code] double stdDev; double sumOfSquaresOfDifferences = 0; for (int i = 0; i < size; i++) { sumOfSquaresOfDifferences += pow(average[i]-a,2); } stdDev = sqrt(sumOfSquaresOfDifferences/(size-1));[/code] to increase …

Member Avatar for Lerner
0
149
Member Avatar for perumar

>>how can i add main for this First, develop a protocol to display a Vector2D object. You could write a class method or you could overload the << operator for the Vector2D class. In my example below I assume an overloaded << operator has been developed. Second, you might consider …

Member Avatar for Lerner
0
274
Member Avatar for lancevo3

Not sure what this is supposed to mean: >>I have to modify my sort function so that when a character is passed through it which is coded in main not given by a user it arranges it by that. If you are supposed to let user decide what gets sorted …

Member Avatar for VernonDozier
0
157
Member Avatar for Drifter666

[code] void CharNode::headInsert(CharNode* &head, char *d) { head = new CharNode(d, head); }[/code] What the above says is create a new list every time you insert a new item. T'm almost positive that isn't what you want. I strongly recommend you have two classes, not one. One to define a …

Member Avatar for Drifter666
0
3K
Member Avatar for sfrider0

I find your problem description difficult to read/decifer. I would start by putting the following lines: cout << "num is " << num << endl; cin.get(); between these two lines: inFile >> num; intList.InsertItem(num); to be sure you are reading in what you think you are. I suspect the reason …

Member Avatar for sfrider0
0
482
Member Avatar for YingKang

Try sending form() to getData() and pass row by copy rather than by reference. Within getData() assign the actual seat number by converting input row number and column char to appropriate index numbers for the array. No need to cast anything that I can think of. It will complicate the …

Member Avatar for YingKang
0
3K
Member Avatar for AnGuRuSO

Since you are storing pointer to type objects why not try using polymorhism by writing a base method called displayPay() declared with the keyword virtual that would be overloaded with in each of the inherited classes. Then you can loop through the vector of pointer to StaffMembers calling the displayPay() …

Member Avatar for AnGuRuSO
0
883
Member Avatar for vijaysoft1

First define how you want the file to be structured. Given the variable length of several of the member variables (strings) within struct objects I would probably go with writing each variable to file separately rather than trying to use the write() stream member function. Given the possibility of space …

Member Avatar for Lerner
0
107
Member Avatar for daviddoria

Why not start with a list of Clusters. Say each Cluster starts as a list of points having size of one. If you wanted you could start with the first Cluster. Find the closest Cluster to it. Merge the two. Repeat until you have come to the end of the …

Member Avatar for daviddoria
0
118
Member Avatar for kuru225

Write it out by hand. It might start like this: [code]enter two numbers. calculate the product of the two numbers. determine which number is larger, call it A, and call the other number B. use an accumulator, initialzed to zero as long as A is above zero if A is …

Member Avatar for kuru225
0
169
Member Avatar for nito28

A is a square matrix. In C++ that means A is a multidimensional array of doubles like this: double A[x][y]; where x and y are constants and known at compile time. Alternatively, since x and y probably won't be known at compile time, then you can use dynamic memory to …

Member Avatar for Lerner
-1
183
Member Avatar for shea279

C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winioctl.h(641) sounds like you have a name clash with a variable type declared in winioctl.h included when you included the windows.h file. You could check by commenting out the windows.h include and recompiling.

Member Avatar for greg022549
0
469
Member Avatar for FREEZX

l is a terrible name for a variable because it is very difficult to tell if it is an el or a one. Ditto for 1. Use something more desciptive, maybe something like numDigits. Don't use variable names that are the same as a function name, like find. Again too …

Member Avatar for FREEZX
0
152
Member Avatar for Moe

you only need to swap the first half with the second. The terminating value for the loop shouldn't be zero. It should be half of count, or something like that. I'd do it by counting j up rather than counting i down, but you should get the drift. And you …

Member Avatar for Lerner
0
340
Member Avatar for perumar
Member Avatar for ARYT

error C2065: 'friction' : undeclared identifier means there is not free standing variable called friction. Yet, on line 23 you write code suggested that's what you want. That compiler is saying you can't do that. friction is a member variable of the Block class, but to do anything with it …

Member Avatar for monkey_king
0
221
Member Avatar for cruisx

You can edit file contents without reading the whole file directly into a program, under some circumstances. To my knowledge there are several situations where this is possible. Under one scenario you read in just the data that needs to be edited, make the changes and write it back. You …

Member Avatar for computercobra
0
832
Member Avatar for cloud21

Here's one possible scenario. All players need to play a card, have a hand, keep a score, whatever, whether it is a computer or an enduser. Maybe you overload that you overload that so the computer outputs snide remarks like "Ha Ha, I won that one", or "Drat" or whatever. …

Member Avatar for VernonDozier
0
209
Member Avatar for erialclaire_238

take out the delay()s. They add nothing to the code and are distracting.[code] scanf("%d",&find); while(loc < 5) { if(nos[loc] == find) { printf("\n The location is: %d", loc + 1); } ++loc; }[/code] For maximum learning benefit explain each change from my code to yours. For better code writing, write …

Member Avatar for erialclaire_238
0
319
Member Avatar for nitheesh.89

Sounds like you have a broad idea presented and you need to develop a project within those guidelines. I wish my boss did that more often! One possibility is to set up computer programming business. Then charge outrageous sums for your services. Say $5 per line for finished code. $3 …

Member Avatar for siddhant3s
0
95
Member Avatar for ammaranasir@hot

Let's see. I want 5 items of type a at 315.74 dollars each. How much is that going to cost? And if I want x number of products y that cost z dollars each how do I keep doing the same type of calculation over and over again as long …

Member Avatar for Lerner
0
62
Member Avatar for trinity_neo

This should get you pretty close. Each term has the form (-1^n)*((x^n)/n!) where 0! is defined as 1 and x^0 is also defined as 1. E(x) is the sum of the number of terms you want to use. You calculate the sum using a running total within a loop adding …

Member Avatar for siddhant3s
0
174
Member Avatar for wonder_laptop

>>i have to create a w64 structure and the array will be of that type. >>a two dimensional array where the first dimension is the 2^14 ( that is 16k) and the other is 8 So do you want something like this?[code] struct w64 {}; w64 buffer[16000][8]; [/code]

Member Avatar for Lerner
0
125
Member Avatar for sweetApple

The whole list is probably irrelevant. Just post a copy of the first 1 or 2 errors you get. The stl_ files referenced by the error messages are probably included in the vector header file. As a wild guess, you might try putting lines 1, 2 and 3 in the …

Member Avatar for Lerner
0
114
Member Avatar for ~s.o.s~

The first two lines of the triangle must be given. However, after that you can calculate each value on your own as needed. One way is to recognize that if you number the lines of the triangle 1 to x then the maximum number of values per line is also …

Member Avatar for creeping death
0
726
Member Avatar for mentos12345

Welcome to the board/community! When posting code please use code tags as discussed in the watermark in the Message box, or in the announcement section at the top of the board. This will preserve the indentation you use (hopefully) when writing code. Without the indentation many of the more experienced …

Member Avatar for Lerner
0
255
Member Avatar for songweaver

digit isn't given a value if select == 1. change the variable used by the switch statement to character instead of digit. Place break statements after the output statement in each case. Otherwise all digit values after the entered value of character will be displayed.

Member Avatar for siddhant3s
0
169
Member Avatar for daniel_16
Member Avatar for xyzt
0
584
Member Avatar for Comatose

Her role as moderator is less important than her role as contributor, though both are highly respected.

Member Avatar for Ancient Dragon
0
1K
Member Avatar for ahfan_85

Is there a reason why you have placed the definition of insertOrd() before the class declaration? Within insertOrd() you need an opening curly brace between these two lines. [code] while(current!=NULL && !found) if(current->info>=newitem)[/code] and you need a closing brace for the while loop as well. Keeping your indentation consistent and …

Member Avatar for ahfan_85
0
127
Member Avatar for cruisx

change this: system("pause"); return(0); } } to this:[code] system("pause"); } return 0; }[/code] Note how consistent indentation helps solve the problem!

Member Avatar for charleen
0
90
Member Avatar for ahfrey85

[code]else { if (seats[position]==0) cout<<"You have booked "<<position<<".Thank you\n"; seats[position]=1; //to change the array from 0 to 1 }[/code] In addition, pay a little more attention to proper indentation. That will allow you to spot errors easier. I suspect you want a set of curly braces around both of the …

Member Avatar for ahfrey85
0
125
Member Avatar for Mossiah

>>Use two strings provided in main and then the function is called to add the rwo strings. That's what strcat() does when using C style strings. Do you mean you need to write your own version of strcat() for educational purposes, that is, you are not allowed to used strcat()?

Member Avatar for William Hemsworth
0
74
Member Avatar for JohnnyG23

I guess there are two schools of thought regarding how to view the content of a queue. One school says you can only look at the top of the queue so you have to pop everything off the queue one element at a time to find out what's in there. …

Member Avatar for Lerner
0
96
Member Avatar for shasha821110

William Hensworth's code declares memory for the new string and copies the char from the original string into the new string, but it doesn't copy the char from other into the new string. You will need to add another loop to do that, but it's only a slightly different version …

Member Avatar for William Hemsworth
0
254
Member Avatar for di mo

Do you intend to allow negative numbers? If not then somehow you have to identify which input is larger, x or y. (Padding the smaller one with zeros if the they don't have the same number of digits is useful, just like with intadd().) The larger ultimately determines the value …

Member Avatar for di mo
0
457
Member Avatar for teddycow

To successfully read a file you need to know exactly how it is organized. If the file is organized with the Album Title on the first line and song titles one per line thereafter like this: Green Chili's Greatest Hits How Hot Dreamy 7 Days and 7 Nights the using …

Member Avatar for teddycow
0
120
Member Avatar for mohammad8065

conio.h isn't bundled with many compilers/IDEs. You can do what you want to do without it by thinking of the page as a grid of cells. The grid can be viewed as lines of cells, like a chess board. Each cell may hold 1 character. Some char may be visible …

Member Avatar for siddhant3s
0
262

The End.