2,827 Posted Topics
Re: [QUOTE=Shaun32887;635448]That's sort of what I was thinking, though I think I may be able to combine the second and third loop using string::copy. Do you think that would work?[/QUOTE] I think that a permutation problem is crying out for recursion. [code=cplusplus] void Permutations (vector <string>& thePermutations, string startOfString, string stringToPermute) … | |
Re: I responded to your question, as did Jishnu. You posted 350 lines of code, but gave a very vague question which suggested to me that you did not know exactly what you wanted. I suggested some questions that I felt needed to be answered that could clarify both to you … | |
Re: [code=cplusplus] //generate 4 numbers for(i=1; i<=4; i++){ weapRand = rand()%4 + 1; //generate a random number from 1 to 4 } if (weapRand = 1){ cout<< "You hit Target A, 100 points"<<endl; charaChoice = charaChoice + 100; } [/code] Two problems. One, in your for-loop, you are creating a random … | |
Re: [QUOTE=Azurea;634760]Hey guys. I'm having an issue with my Dev-C++ IDE where whenever I try to compile my code, I get a " [Linker error] undefined reference to `__cpu_features_init' ld returned 1 exit status " error. Even with simple programs with just sending information to [I]cout[/I] I get this error. Something … | |
Re: [QUOTE=WillMcc;634797]Not quite sure what a++ is or char.... soo... yeah... But I think I figured out what they were talking about... for example: [code] int apples = 1, passes = 0, fails = 0, result; while (apples <= 10) { cout>>"Enter result" : "; cin<< result; if (result == 1) … | |
Re: [QUOTE=ederX;634848]Ok, im pulling my hair out now...Im new to c++ but this one error is eluding me. Probably due to the fact that I'm still trying to understand pointers. Can anyone point me in the right direction to fix this error: [CODE]request for member ‘outputData’ in ‘*(employee**)(& emp)’, which is … | |
Re: [QUOTE=mikelle;634821]// the output is coming out incorrectly. any suggestions? //here is what i have // Lab 4 read and calculation file/input // This program will read the data in the input file // used by grosspayMinustaxFileCode #include <iostream> #include <fstream> using namespace std; int main() // this is the error … | |
Re: I ran your program twice, both times with a key of "a". One time I had the message as "a" and another time as "b". Results for text "a" are: [code] Enter your text here: a Enter your key here: a Plaintext MPDU in transmission order, without CRC 00 00 … | |
Re: You're going to have to be more specific. What's an undirected country? I assume you mean an undirected graph? What's the data look like? Do you have a bunch of latitude and longitude coordinates and country names? Are you given a bunch of countries that are "connected"? Are you given … | |
Re: [QUOTE=SteveDB;632514]ICorey, I had first noticed my issue when the '1' single quote marks were on the numbers in my switch list. I had removed them, and it did not resolve it. I then tried multiple items, and just never repalced them. Ellisande, As to my choice of do-while. At the … | |
Re: [QUOTE=sanchyvil;634123]im new in programming cpp usually i do java... i have this problem, evertime i run my program i cannot see the output well, its just like it blinks... so idk if i have a correct output for my program... tnx...[/QUOTE] The program may be terminating too quickly for you … | |
Re: [QUOTE=mikelle;633949]hello i am trying to make a program that gets numbers from a file and do stuff with it. My question is: Is that file just a file that holds another program that reads out numbers? Like a dummy I just put these numbers in a file and then tried … | |
Re: Lots of good problems from the ACM annual college programming team contest at this link. Many of these are algorithmic problems. The website layout can be a little counter-intuitive, but a few clicks will get you to some problems. It's not really a guide on how to approach the problems … | |
Re: [QUOTE=aintlikeyou;633393]Because I can't answer it. I posted where I am at so that you can possibly answer it yourself :/ I found some of the errors but I definately don't know what to do now :/ [code] #include <iostream> using namespace std; int main() { int rectNum[]; int rectW[]; // … | |
Re: Here's your code with the extra characters removed, formatted, and with code tags. To add code tags, do this: [noparse] [code=cplusplus] // paste code here [/code] [/noparse] or [noparse] [code] // paste code here [/code] [/noparse] The first way adds line numbers and C++ syntax highlighting. The second does not. … | |
Re: [QUOTE=Ancient Dragon;632829]moved[/QUOTE] I assume this is a GUI application, in which case you'll need to get familiar with Java Swing. You'll probably want to create a JFrame, then add at least one JTextField and quite a few JButtons to the JFrame to create the calculator. You'll need to either set … | |
Re: [QUOTE=thehype2049;632456]Here is my question Write a command line program titled joinTextFiles.cpp that concatenates the contents of several files into one file. For example, the following command line [B]joinTextFiles chapter1.txt chapter2.txt chapter3.txt book.txt[/B] will create a long file titled book.txt that contains the contents of the files chapter1.txt, chapter2.txt, and chapter3.txt. … | |
Re: Not sure whether this is what you are after, but from this line: [quote] isn't there a way that you can initialize an array later using the method you can when first initializing them? (int tower_dmg[5][3] = {{#,#,#}, {#,#,#} [...]}) [/quote] I figured I'd post this, though it sounds like … | |
Re: [code=cplusplus] // include libraries #include "stdafx.h" #include <time.h> #include <iostream> #include <cstdlib> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { // declare variables int computerChoice; char userChoice; char wins = 0; char losses = 0; char ties = 0; // seed the random number generator with the current time … | |
Re: [QUOTE=windscar;632357]What's used to storage 2d data like this: ID --- ITEM ------ TYPE ------ PRICE ------ WEIGH 1 ---- hammer ---- 3 ---------- 1300 ------- 67.0 2 ---- sword ------ 2 ---------- 800 --------- 42.0 3 ---- katana ----- 2 ---------- 2200 -------- 21.0 So I can acess it to … | |
Re: [code=cplusplus] #include "freefun.h" using namespace std; int main() { ofstream streamout; ifstream streamin; char infile[16]; char instring[100]; int i=0; cout << "Please input the filename you would like to open up to 15 characters." << endl; cin >> infile; streamout.open (infile); if (!streamout) { cout << "Unable to open file: … | |
Re: [QUOTE=salman213;632032]would this be better or worse :(??? [code] #include <iostream> using namespace std; int check (unsigned int checkvariable[]); int main() { srand(time(NULL)); unsigned int lotteryBall[9]; for(int i = 0; i <=7; ++i) { lotteryBall[i] = rand() % 48 + 1; cout << lotteryBall[i] << " "; if(i == 7) { … | |
Re: [quote] [code] /* as long as actual birthday has occurred life is fine however if birthday has not occured.. wrong date */ //progam which calculates birthDate, todaysDate, leapYears and then //determines how many days the user has been alive [/code] [/quote] Life is not fine when birthday has already occurred. … | |
Re: [QUOTE=salman213;631612]which way is "obfuscatory?"[/quote] Well, you are given two ways of doing the same thing: [code] int c = (a * 10) + b; int c = (a << 3) + (a << 1) + b; [/code] One of them is straight-forward, one is not. The one that is not … | |
Re: [QUOTE=salman213;631535]is it possible to think of it as a matrix? for example [code]char array[2][2];[/code] Isn't this what we are forming [code] 0 1 0 1 [/code] If we do [code]cin>> array[0][/code] and we input the word: "WHAT" how is that being placed in to the matrix I drew. To display … | |
Re: What is words.txt? Is it just a text file with ten random words from the dictionary? | |
Re: I'm not sure whether I like the idea or not, but I like the thread. It's a more interesting topic than many in the Geek's Lounge; a nice change-up from a lot of the other threads, which are often just links to a YouTube video of a cat juggling while … | |
Re: [QUOTE=Alex_;628420]My problem is that i can not understand what do they mean by "The application of mathematical algorithms analisys for solving the 'perl calculus' problem". the perl calculus problem sounds like this: we have 3 ordinary perls(1,2,3), and 3 magic perls(A,B,C). Each magic perl can transform itself in the following … | |
Re: Please use code tags. It makes your code much more readable. What are the criteria for whether one student is less than another? You need to write a comparison function: [code] int StudentCompare(student student1, student student2) { // return -1 if student1 is less than student2 // return 0 if … | |
Re: [QUOTE=comply or die;627601]Hi I'm pretty new to programming started about 3 months ago, and even though I feel I'm getting better, I still find it not easy at all, I got especially trouble with that code, look I want to put into an array of strings sentences with spaces, etc. … | |
Re: Please flag each file with its exact file name. Two, some of these errors don't match the line numbers. Please make sure the line numbers you've listed correspond to the error message or point us to the REAL line number from where you've posted. Example: [code] 42 C:\Documents and Settings\mugjy001\Desktop\Dev … | |
Re: [QUOTE=atsx05;626877]Write a program which consists of four functions called from the main( ). The first function will display the user heading; the second function will prompt the user to fill an array of strings (a two dimensional array of char) with a number of words and indicate the preference for … | |
Re: [QUOTE=abhishek23;627553]hi guys well I go to my dos prompt and invoke the compiler with the javac command but I always get the following message: javac is not recongised as an internal or external command,operable program or batch file I would like to know why i am gettin this message and … | |
Re: [QUOTE=henpecked1;627194]I'm being asked to make my default constructor "interactive" by having it prompt for an input and store the three phone number pieces you see below. They are strings, and they get called for display in main with the telnumber yournumber piece of main. How would one do that? [code] … | |
Re: You guys must have been home schooled. No one can go through preschool and elementary school without having been exposed to Cooties. I see neither of you are from the States, but I had thought Cooties was a worldwide phenomenon. | |
Re: [QUOTE=dwessell;627457]Hi, I'm trying to read in a section of a line from a file, and to compare that to an integer. I know that the piece I'm reading in will be 3 numbers (xxx) and be followed by a space. It will also be the first entry on each line … | |
Re: [QUOTE=hezfast2;627395]OK, here's what I've attempted so far. It is still not working and I'm not sure I have the search algorithm correct for vector lists. Can anyone point me in the right direction? If I need to post my code I can, it's just a big program. Thanks [code] QuestionInfo[] … | |
Re: I don't see a constructor for this call. [code] Airport a("syd",0.30,"Sydney domestic airport",C); [/code] So do you have the above constructor implemented in your code? I didn't see it. If you do not, you cannot make the above call. The closest I see is this: [code] Airport::Airport(const std::string &,const double … | |
Re: You don't need to use an ifstream to use getline. You can use getline with cin and thus read in more than one word. The program below asks the user to type in two sentences, then displays both. Unlike the >> operator, getline doesn't stop at the first space, so … | |
Re: So is this the input file? [code] -1 0 5 1 20 3 -9 2 -2 1 1 2 -2 3 1 9 6 3 2 2 -1 1 10 0 5 2 -2 9 10 3 4 0 -3 1 1 1 6 3 -4 3 -5 2 8 … | |
Hi, I am writing a program where I want the user to be able to e-mail me feedback, so I have downloaded javax.mail and I'm trying to send myself an e-mail to test it out. I have Yahoo Mail Plus. Below is my code, which I tweaked from one of … | |
Re: To sum an array with numElements number of elements, you can initialize the sum to 0, then loop through the array, adding each array element's value to the sum. Assuming array is a[] and there are numElements elements in the array: [code] int sum = 0; for (int i = … | |
Re: [QUOTE=bookworm619;622951]I am thanking all for the help. I appreciate it so much. I couldn't find a better teacher than you guys. With your advices and corrections, I still get thos errors?? [code] error C2143: syntax error : missing ';' before '%' include\xlocnum(1) : error C4430: missing type specifier - int … | |
Re: [code=cplusplus] #include<iostream.h> #include<conio.h> #include<iomanip.h> int userInput(); int main() { clrscr(); int x,y; const int row= 12,seat= 5; char plane[row][seat]; cout<<"\t\tAirplane Seat Arrangement"<<endl; cout<<"\tA\tB\tC\tD\tE\tF"<<endl; {for (y=1;y<=13;y++) { cout<<"Row "<<y<<"\t"; {for(x=0;x<=5;x++) { plane[y][x]='*'; cout<<plane[y][x]<<"\t"; } cout<<endl; } } } userInput(); cout<<"Congratulations!! You Now Have A Seat...." <<" Happy Trip!!!"; getch(); return 0; … | |
Re: [QUOTE=warrior16;623891]Are you retarded....? Please post up the code, quit being lazy. Maybe if you make it easier for us to help, then maybe we will share our knowledge with you, maybe. IMHO your trying to hard.[/QUOTE] Overly harsh, and unnecessary, in my opinion. The OP posted code and made a … | |
Re: [QUOTE=SakisLam;624813]Let's say I have the integers A1,A2,A3 and x. I want when the value of x is 2 (for example) , the caption of a label to return A2's value. If x = 3, to return A3 value and so on. How do I do that? Thanks a lot.[/QUOTE] I'm … | |
Re: I read in another one of your posts that you are a "first year" student, if I recall correctly. Alex raises some good questions, but I think they may be a bit more advanced than "first year". At least they were at my school (CSU system). Maybe some of the … | |
Re: [QUOTE=daviddoria;623985]I have a file that contains lines like: 2/3/4 5/6/7 8/9/10 and I want to extract the 2, the 5, and the 8 So I am parsing the line by the ' ' delmiter to get 2/3/4 5/6/7 8/9/10 then I need to parse each of those to get the … | |
Re: [QUOTE=Latte;623974]How to count line of code in text file or file .cpp (this .txt file or .cpp file is the input file of program) and what's function for count line of only mark code for example of this code(file input) , I want to count only "do" function that have … | |
Re: [QUOTE=Flixter;623808] But here void main() { vector<Point> allPoints;.... ... give me error message :S Can someone help me?[/QUOTE] That's not the problem. You can comment out your entire main function and you'll still get an error. If you comment out this line: [code] sort(P.begin(), P.end()); [/code] your program should compile. … |
The End.