Saturday, May 22, 2010

C++ HELP, I can get the program running, but I can figure out how to add things together from a inFile.?

#include %26lt;iostream%26gt;


#include %26lt;fstream%26gt;


using namespace std;





int main ()


{ double sum;


int count ;


int val;


ifstream infile;


char a,b,c;





infile.open ("p3_data.txt");


if (infile.is_open())


{


while (infile.good())


cout %26lt;%26lt; (char) infile.get();


infile.close();


}


else


{


cout %26lt;%26lt; "Error opening file\n";


}





cout %26lt;%26lt; "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=...


cout %26lt;%26lt; "\nPlease enter either A, B, or C to be calculated!\n";


cin %26gt;%26gt; a%26gt;%26gt;b%26gt;%26gt;c;


cout %26lt;%26lt; "\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-...


cout %26lt;%26lt; "The bills add up to "%26lt;%26lt;endl;


system("pause");


return 1;


}


/*My program is only adding up 3 different things A B C. I can do everything else I just cant figure this one out. */


Thanks for the help

C++ HELP, I can get the program running, but I can figure out how to add things together from a inFile.?
I'm not exactly sure about what you are trying to do, but if you are trying to add up three numbers, each separated by spaces, one per line, then this might get you started:





#include %26lt;iostream%26gt;


#include %26lt;fstream%26gt;


using namespace std;





int main ()


{


ifstream infile;


int a,b,c;





infile.open ("p3_data.txt");


if (infile.is_open())


{


while (!infile.eof())


{


infile %26gt;%26gt; a %26gt;%26gt; b %26gt;%26gt; c;


cout %26lt;%26lt; a %26lt;%26lt; " + " %26lt;%26lt; b %26lt;%26lt;


" + " %26lt;%26lt; c %26lt;%26lt; " = " %26lt;%26lt;


a+b+c %26lt;%26lt; endl;


}


}


else


{


cout %26lt;%26lt; "Error opening file" %26lt;%26lt; endl;


return 1;


}





infile.close();


return 0;


}
Reply:Use "write()" method of fstream class to write the data into file.


Are double jogging strollers allowed on airplanes?

We'll be going home to visit soon so I wanted to buy a double stroller but I don't want to waste money b/c i want a jogging stroller so that my husband and I can go running together with the kids in the stroller instead of taking turns.But I didn't know if I can also take in on the airplane when we go home to visit or not, I hope so it'll make things so much easier.

Are double jogging strollers allowed on airplanes?
What kind of stroller you have doesn't matter but you can't take them onboard. First, there's no way to stow them. Even on a 747, the closets are limited. Strollers are dangerous in overhead bins and should never be placed there anyway.





When you check-in, they'll tag it. You can then use it to get to the gate and you leave on the jetway, after folding it, where it will be loaded into the hold. When you arrive at your destination, it will again, be on the jetway.





If you don't have a jetway, it'll be on the tarmack, next to the "airstairs" when you come down.





Some tips;


-Make sure of the procedure I just described. This is how it is at the majority of airports but there are always exceptions so don't assume, ask!


-Remove all the "extras" like the cup holders, any toys, etc. Depending on the design, perhaps pack the sunshades.


-Attach the straps


-Bring a bungee cord to double secure it. If it pops open en route, don't have them smashing it together.


-When you disembark, if there is more than one door, ask which one has your stroller. It also might be annouced after landing so listen. This will avoid the inconvenience of going through the wrong one and having to snake back onboard to get to the other door, etc.





Sometimes you can cover them in a big plastic bag but I suggest this if you check it in intially. Only do this if you wont need it to get to the gate.





Get something really sturdy. They can get damaged, even with gate-checking, which is supposed to be gentler. Something that folds well might also be a consideration. I will say after 3 kids and my fair share of strollers, you get what you pay for.





Your other alternative is to use two umbrella strollers for travel. You wouldn't be able to jog on your visit though. I actually never use my double. Even alone with three, I manage with only one stroller, a baby carrier and one who has to walk.





I was a F/A for 13 years, most of it "pre-baby". Now I fly between Europe and California with my three about every six months plus shorter flights in between. I wrote a totally non-commercial article on flying with children, which I put on a blog to share. When you go to fly, you might find it helpful;


http://flyingwithchildren.blogspot.com





Happy shopping!
Reply:check it!
Reply:In the cabin? No, you can't. You can either check it at the counter, or take the kids in it up to the gate and they'll check it for you there.
Reply:I believe it will count as a piece of luggage and with the limitations on poundage and piece number it might be a better idea if you can to either buy it and ship it ahead of where your going or get it there and ship it back home to where it is your going home to.





It would be so much better to have that convenience on a trip but it will take away from what your able to actually take "on the plane". If you know someone where your going then just ship ahead and ship afterwards. Even Greyhound bus will ship something back for ya but it will take a few days before it gets there.





Sometimes the convenience of flying isn't always just that it takes a little planning to have a fun trip for the whole family.





.......think about it and find a way and have a great vacation!....
Reply:all strollers are taken from travelers at the door of the plane and tagged and stored. They are returned to you when you get off the plane at your destination. So the jogging stoller shouldn't be treated any differently from another type of stroller.
Reply:yeah, you can take it but it will have to be gate checked...see an agent at the airport when you arrive.....it is most definately allowed...im a ticketing agent for united


Minesweeper in C++?

Hello, I am trying to code a MineSweeper in C++. My question is, say that I want to use Double Dim arrays, how would I actually generate random mines, and input numbers from one to ten into the array, including mines which are represented by a star?

Minesweeper in C++?
http://answers.yahoo.com/question/index;...





You want to input into the array? Loop over it, repeatedly asking for input.





EDIT:


%26gt;%26gt; I want the array to be filled out either by a loop, or from a file


Fine, so either read in the mine distribution from a file, or use some random distribution to fill up the array.





%26gt;%26gt; how would I actually randomly place them into the double dim array?


So you know that random access to an array is something like array[i][j] where array is your variable name, i,j are indices. So, there's pretty much two ways of doing this.





1) Loop over the array. Since you have a 2D array, that's two loops, right? Because for each loop over a row, you need to loop over the column. Then use some probability function to determine whether each point in the array is a mine or not.





2) Create a vector of x,y coordinates using some probability function. Then loop over this vector of coordinates. So for each coordinate, you access the appropriate point in the array and set it to be a mine.





Also, what are Double Dim Arrays? You wouldn't happen to be a VB programmer would you? There's no such thing as Dim in C++.





EDIT2:


Amanda, you realize that array[i,j] syntax is not valid in C++? Your code is wrong.
Reply:For minesweeper on a square grid, you only need numbers zero through 8. Those numbers are determined by where the mines are placed. Probably the easiest way would be to place the mines first, and then calculate and insert the numbers.





To insert the mines, use a while loop like this:





X_DIM=10; //set this to how many columns


Y_DIM=10; //set this to how many rows


NUM_MINES=10; //set this to how many mines you want


x=0;


srand(time(null)); //dont forget to include time.h


while(x%26lt;NUM_MINES){


column=rand()%X_DIM;


row=rand()%Y_DIM;


if (GRID[column,row]!='*') {


GRID[column,row]='*';


x++;


}





}





Then to calculate the numbers, you would just look at the neighbors of each grid position and count the stars, so just use two for loops to go through the grid.





for(row=0;row%26lt;Y_DIM;row++)


for(column=0;row%26lt;X_DIM;column++){


if(GRID[column,row-1]=='*') COUNT++;


if(GRID[column-1,row-1]=='*') COUNT++;


if(GRID[column+1,row-1]=='*') COUNT++;


if(GRID[column-1,row]=='*') COUNT++;


if(GRID[column+1,row]=='*') COUNT++;


if(GRID[column,row+1]=='*') COUNT++;


if(GRID[column-1,row+1]=='*') COUNT++;


if(GRID[column+1,row+1]=='*') COUNT++;


}





Note that the above loop doesn't account that some of the GRID positions checked are out of range, and will likely cause issues, so make sure you include extra checks to make sure you don't run out of bounds.





EDIT:





Ack. Its late and Im tired. Of course the code is wrong. Instead of [x,y] it should be [x][y].





Too lazy to fix.

hibiscus

MineSweeper in C++?

Hello, I am trying to code a MineSweeper in C++. My question is, say that I want to use Double Dim arrays, how would I actually generate random mines, and how would I make it so they have to choose between numbers, say 1 to 100 in a 10 x 10 grid? Thank you. Any help would be greatly appreciated.

MineSweeper in C++?
%26gt;%26gt; how would I actually generate random mines





Use some algorithm to populate the array with mines. There's various ways to create a random distribution, and you can either create something simplistic or Google for various mathematical descriptions of distributions and random generators.





%26gt;%26gt; how would I make it so they have to choose between numbers, say 1 to 100 in a 10 x 10 grid?





Ask them, then take in an integer as an input.


C++ Help... I cant figure this one out.. Please help.?

#include %26lt;iostream%26gt;


#include %26lt;fstream%26gt;


using namespace std;





int main ()


{ double sum;


int count ;


int val;


ifstream infile;


char a,b,c;





infile.open ("p3_data.txt");


if (infile.is_open())


{


while (infile.good())


cout %26lt;%26lt; (char) infile.get();


infile.close();


}


else


{


cout %26lt;%26lt; "Error opening file\n";


}





cout %26lt;%26lt; "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=...


cout %26lt;%26lt; "\nPlease enter either A, B, or C to be calculated!\n";


cin %26gt;%26gt; a%26gt;%26gt;b%26gt;%26gt;c;


cout %26lt;%26lt; "\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-...


cout %26lt;%26lt; "The bills add up to "%26lt;%26lt;endl;


system("pause");


return 1;


}


/*My program is only adding up 3 different things A B C. I can do everything else I just cant figure this one out. */


Thanks for the help








***A B C are three different groups with about 20 numbers in each group. I need to add the numbers and get an average. I need it to be able to print out like this


::package A 9.95 for 15 hours monthly. additional hours are $2.00 per hour





Please Help

C++ Help... I cant figure this one out.. Please help.?
call a computer store
Reply:Doesn't do anything that makes really sense. It just declares some variables (look at in variable definition), then opens a file and reads its records and close it, doing nothing with the information that reads (I need to double check the function to read a record is valid and works). Then it display some text on the screen "======" and "-- please enter, blah blah". Ask the user for 3 variables, a, b, c, that are of type charcter, be careful that can't enter more than just 1 character, display more text on the screen "======" and then says that "The bills add up to", the system enters into a pause until the user press any key, "press any key to continue..." is what (system ("pause")) is going to cause, and returns 1 as a result, it looks like is a function and it returns a numeric value. That's all it does but it doesn't make any sense, if it is a function to do something with sense, it hasn't been finished or it was put on purpose to just read what it does.


Does anyone know when does yahoo's fantasy sports update player positions (C,LW,RW) for fantasy hockey?

For example, Brian Rolston is only listed as RW


last year he was a LW, C, RW player


and there are no players with double positions


i would just like to know if yahoo posted an updating date or something.

Does anyone know when does yahoo's fantasy sports update player positions (C,LW,RW) for fantasy hockey?
Last year was sept 30. I think it should be the same this year.





Good Luck











http://sports.groups.yahoo.com/group/pro...


Is a c cup bra big?

well,i'm thirteen years old in the eigth grade and i am a 32 c cup.my friend is 14 and a 36 c cup.and we were having a talk about whether a c cup is big,small,or in the middle.she said that a c cup is big and i said that it is right in the middle.i just recently became a c.cup. i was a 34 b and now a i'm a c.all my friends are making a big deal about my size.and i don't know why.my other friend is a 36 double d yeah i said it,and she says that a c cup is small.what do u think?

Is a c cup bra big?
haha well considering that im almost 18 and im a 34 A !!! haha yeah they are pretty big for your age. ( to me at least =p )





p.s. i am so jealous!!! =p =]
Reply:You are about average (:
Reply:A C cup is average. Yup.
Reply:i believe it depends on your weight, heath and state of mind, and generally C considered medium
Reply:It's a little above Average. B is average.





Your kickin some girls butts.





=]





http://answers.yahoo.com/question/index;...
Reply:average but It depends on yuor body weight and height
Reply:its average
Reply:For me a C cup is big for a 13 year old...but thats because i'm a small B. It all depends on your figure.
Reply:I think C is average, there are big c's and smaller c's. A 36 c will look bigger than a 34c. Most girls also dont wear the correct size bra. You are very young, so I imagine they will still grow. So I hope you like em big
Reply:a c cup is medium to big. most 13 year olds are a b, but a 32c is not HUMONGOUS. but its not tiny either.
Reply:I think that for your age, you are a bigger average. I was very large at a 36 tripple D at your age. I now top out at 42 H. you are lucky to be the size you are.
Reply:i consider it big, not like ungodly huge, but very plump lol. considering i am a 34 A! and 16 yrs old!!! wooo and proud! hahah :)

hydrangea