2,827 Posted Topics
Re: > Also make sure your code is well structured and well documented! No! That's time better spent just getting the darned thing done, getting the points, and getting to the next problem. No contest I've seen cares about anything other than whether the code works. You aren't writing maintainable code. … | |
![]() | |
Re: On the "didn't like" side, put me down for not liking the Bar Rafaeli ad. Normally I find it a good thing when the not-so-good-looking guy has a shot with the hot babe. Not this time. | |
Re: [QUOTE=bramprakash1989;572363]i tried the following coding .it compiled without errors but gave absurd results during runtime. can u pls help me with it? #include<iostream.h> #include<stdlib.h> int main() { int i; cout<<"ten random numbers for the range 0 to 50"<<endl; for(i=0;i<10;i++) { cout<<rand()<<endl; return 0; } }[/QUOTE] You probably want the "return … | |
Re: Am I the only one having a problem following this thread? My X-Ray vision has gone bad, so I can't tell whether you guys are actually writing bad words that are getting filtered or just ####. I've seen bad-word filters where only a couple of the letters are blocked out … | |
I am looking for a portable method of checking whether overflow has occurred when multiplying unsigned integers. The way I have always done it in the past is to turn my unsigned integers into uint64_t's, multiply, then create a uint64_t with a value of 2 to the 32nd power and … | |
Re: If you can print the first 500 prime numbers, you should be able to tweak the program to print ONLY the 500th prime number. You are printing in line 30. Do an if-test on the count variable. Execute line 30 ONLY if count is the correct value. In other words, … | |
Re: I think firstPerson meant to do this with his line 22. student kyle; kyle.input(); Create an object with the default constructor. Then fill it in with the input function, which should take NO parameters. | |
Re: There's nothing specifying that the numbers have to be positive. In that case, there are an infinite number of solutions, or since we're talking computer, "billyuns and billyuns" of them as our favorite astronomer used to say. v = w = x = 3. y and z and arithmetic inverses … | |
Re: Use the / and % operators to perel off and isolate digits. For example, if x = 12345678, to isolate the 345, you would first divide by 1000 to get rid of the 678 and end up with 12345, then to get rid of the 12 part, you would mod … | |
Re: [QUOTE=fierykido;621801][COLOR="Red"]some say[/COLOR] that in 2012 december 21 we are going to enter a new era call the golden age and [COLOR="Red"]other says[/COLOR] that a new sun cycle has already started and the sun storm will be too big and somehow kill us.thats by the NASA i think but [COLOR="Red"]yet another … | |
Re: To get back to the actual scientific answer, I believe Ene Uran had it right a while back. An evolutionist is going to say that the egg came first. > Evolutionists: > An almost chicken laid the egg the first real chicken came out off. > Creationists: > God made … | |
Re: * Stick a "return 0" in there at the end of main. * Count your opening and closing brackets. Make sure you don't have a bracket mismatch. * Get rid of the stray semicolon after the final bracket. | |
Re: You're a high school freshman and you can do a four minute mile? That should be a U.S. record for the 15 to 16 year old age group. http://www.usatf.org/statistics/records/view.asp?division=american&location=outdoor%20track%20%26%20field&age=youth&sport=TF Scroll down. Record for 1500 meters (shorter than a mile) is 3:54.02 in the 15 to 16 year old category. If … | |
Re: [QUOTE=FtKShadow;694512]I am trying to get my homework assignment to work for class, but I cant seem to get it. Heres the assignment. Seems not to bad doesnt it? Well I have been working for a while and it still isnt working for me. I enter lets say a 4 it … | |
Re: > the program shouldnt display the previous numbers counted. Do I take this to mean that there should be no output? Or should there be a countdown from 30 to 0, with a delay in between each iteration, then there is a "Screen Clear" and the new number is displayed? … | |
Re: Forget the computer for a bit. Think of the algorithm. How would you do it with pencil and paper? What steps would you take? Write the steps out exactly. Follow the steps exactly to make sure they are right for all scenarios. Now go back to the code and make … | |
Re: [QUOTE=SpecialeW;529887]hi, how can i make sure that when i ask a yes no question, i don't get rubbish for an answer. i have tried some while codes, but i seem to do something wrong, because when i execute the program i can enter anything i want... this is what i … | |
![]() | Re: I'm reading the function name. I see a function called **addBook**, not **addBoooks**. Hence I am expecting to one book, not many. I am hoping this is the intent. One book, not twenty. I am confused by your description of what is occurring. You are entering something 20 times, not … |
Re: Code tags: [noparse] [code=JAVA] // paste code here [/code] [/noparse] Code looks terrible without them. This looks like a cut and paste of the assignment specification that someone gave you. What seems to be the problem? ![]() | |
Re: This is a matter of going line by line and changing the code to C++. All variables in C++ must have a type (i.e. int, char, string, etc.) and must be declared before you use them, so a good start might be to figure out what variables you need and … | |
Re: You have not posted the declaration of dna1, so it's hard to say exactly where you are going with this. Regardless, having the brackets operator without an array index seems like an error. if(!dna1[].strand1){ Does the compiler let you do this? Then later you have this... cout<<"<"<<sizeof(dna1.strand1)<<">";} Is dna1 an … | |
Re: [QUOTE=joshmo;877835]Ofcourse I can get to understand the logic..What I want to know is how i can get, say a given equation to integrate or differentiate a number, then change that logic, to JAVA code..is there any application or tool that can do this?[/QUOTE] Depends on the equation. A lot of … | |
Re: You need the ruler to break the candle in two. If you have the ruler, then Dani's solution has it covered. All these solutions only need ONE candle, yet we have two of them. Is the second candle a red herring? I think we can assume we have matches. Not … | |
Re: Consider using the "at" function instead of the [] operator and catching the error. You have a 2 dimensional vector. You need to find out which one gives the error. For some debugging... cout << i << '\t' << j << '\t'; cin.get(); cout << grid.size() << '\t'; cin.get(); cout … | |
Re: What exactly is the problem? Possibilities might include... * Reading from file. * Writing to file. * Iterating through the list. * Swapping elementss that are out of order. * Not understanding the bubble sort itself. I see no non-commented out attempt to do a bubble sort, so obviously things … | |
Re: [QUOTE=Alex_;889004] I know there is another thread about the same subject but it's been dead for years. And nobody pays attention because of the silliness of the poster.[/QUOTE] There are a couple of THOUSAND threads regarding project ideas and as a result, most get ignored or flamed. However, I won't … | |
Re: [QUOTE=savinki;620158]Hi, wt is the function that can use to count number of digits in a long integer? e.g. 12345678 -> 8 11 ->2 456 -> 3 6724 -> 4[/QUOTE] I don't know that there is a function that does that. You can do two things though. You can use the … | |
Re: Line 43 seems way off. I'll take your word that this compiles and runs, but even so, line 43 is definitely wrong. I'm assuming that line 43 is supposed to be a function call. However, it is NOT a function call. Function calls don't have the return type and parameter … | |
Re: > i have to copy and rename the output file in each step so that they can be used in another program . "Copy" AND "Rename"? So you start with a file named a.txt and you are supposed to end up with what? one file? Two files? A file named … | |
Re: Use the iostream library to read in data from the file into a card type and card number. How best to do that will depend on how the information is arranged in the file. A common way to set up a file would be to have two fields per line, … | |
Re: [code] void CoinChanger::getCoinChange(int &DollarCoin, int &QuarterCoin, int &DimeCoin, int &NickelCoin, int &PennyCoin) { this->DollarCoin = DollarCoin; this->QuarterCoin = QuarterCoin; this->DimeCoin = DimeCoin; this->NickelCoin = NickelCoin; this->PennyCoin = PennyCoin; }[/code] This is a set function, not a get function. Either rename it or make it an actual get function. [code] void … | |
Is there still a "noparse" option? I tried posting the following in the C forum (let's see if it works here). Error message is as below. > The code snippet in your post is formatted incorrectly. Please use the Code button in the editor toolbar when posting whitespace-sensitive text or … | |
Re: struct Card { const string rank[13] = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"}; const string suit[4] = {"Spades", "Hearts", "Clubs", "Diamonds"}; }; These are string arrays. The only purpose of them is to provide a quick way of converting a number from 0 … | |
Re: The || operator is the "logical or" operator. the | operator is the "bitwise OR" operator. The |= operator combines the bitwise OR operator and the assignment operator. Thus the code above is equivalent to the code below. #include <stdio.h> #include <stdlib.h> int main() { int a=8,b=3; int c = … | |
Re: > is it possible to print both statements of else If you are using the if-else clause as intended, either the code in the "if" part will execute or the code in the "else" part will execute, but not both. Now if the question is "Can I print 'Hello World'" … | |
Re: Quite a few questions in this thread. Not sure which ones are still relevant and which are already solved. First, from an overall design, there is more than one way to do this. There are two main ways and you have mentioned them both. One is to have the Card … | |
Re: Who wrote the code here? Is this code you have been given or did you write it? I've never seen this style of doing things. I always did it more like this... struct Student { string name; int id; int* markPtr; Student(); }; Student::Student() { markPtr = new int [100]; … | |
Re: I'm searching your code for the phrases "pop" and "push" and not finding them. You can't have a queue or a stack without "push" and "pop" functions. You probably have them in the code, but are calling them something different. I see "malloc" in the hireEmployee function, so my guess … | |
Re: > Why I can't create a new Cat I'm searching for the phrase "new Cat" and not seeing it, except in a comment. Also, capitalization counts. "Cat" and "cat" are not the same... sc1->method("Cat"); if(something == "cat") Not directly relating to your problem, but still needlessly complicating your code is … | |
Re: First off, I DO NOT get an error with the second program using gcc 3.4.5 on Windows XP. What error do you get? #include<stdio.h> int sum( int ,int,int ); int main() { int a=5,b=2,c=20; int d; d=sum(a,b,c); printf("c=%d",d); } int sum(auto int a,auto int b,auto int c) { return a+b+c; … | |
Re: [code=cplusplus] void move( int n, char*s, char*i, char*d ) // s stands for source tower // d stands for destination tower // i stands for intermediate tower { if( n > 0 ) { move( n-1,s,d,i ); // move n-1 disks from source to intermediate tower cout << "disk " … | |
Re: I'll point out the obvious. One, this doesn't compile. Two, sortMe is not written. Am I correct in assuming that this is the code you have been GIVEN and the task is to change it so things work? If so, you're going to have to ask a specific question and … | |
Re: You can enter it on the command line or you can enter it when you ask the question and read it in with fgets or you change your program slightly and hard-code the path directly into your program (see below). Note that fgets leaves in a newline from the input … | |
Re: > // in binary 0011 0000 that is its 4th and 5th bits are set; Incorrect. 30 in binary is 00011110. Type in 4 and you get 1 << 4, which is 16 in decimal. 00000001 shift left 4 ---> 00010000. When you AND 00010000 & 00011110, you get 00010000, … | |
Re: You've told us what it DOESN'T do. But what DOES it do? You'll need some newlines in your printf statements if you want things to print on separate lines. As for the main problem (which I assume is that the spaces are not weeded out), a space is a legitimate … | |
Re: I think I've found a way to do in at most six races. I have not totally convinced myself that it cannot be done with fewer, but I think the logic below proves all possible cases can be done in at most 6 races. Horses will be names H1 through … | |
Re: Does everything have to be in one file and in one language? For example, what about, say, a C++ program that uses a class connecting to a Java program for the GUI. That's a main.cpp file, a .h class file, a .cpp class file, and the Java file, so that's … | |
Re: Perhaps a namespace issue? Do you have either of these after the `#include <string>` line? `using namespace std;` `using std::string;` Alternately, you can replace `string str;` with `std::string str;` | |
Re: Same answer as on your other thread. To reiterate my points on that thread and possibly add some... * The question is quite vague. There are all sorts of simulators. I could give you advice on a priority queue using STL, then have you say you're not allowed to use … |
The End.