K so if someone has a compiler on them they may be able to tell me or if you know anyway;
Suppose I declare an array of 5 strings.
vector%26lt;string%26gt; word(5);
The I use cin to input values saying;
cin%26gt;%26gt;word(0)%26gt;%26gt;word(1)%26gt;%26gt;word(2)%26gt;%26gt;word(3...
When the program runs and I am prompted for input I write.
" apples bear lemon party "
With all these spaces in there, will C pick out the words and store them in their respective string variables?
Are the vals:
word(0) is "apples"
word(1) is "bear"
word(2) is "lemon"
word(3) is "party"
-What is word(4), is it " " ie a single space, is is a number of spaces, or is it some weird thing without a value or a random value?
Can I use a simple if statement to check for such blanks?
if(word.at(4) == ' ') %26lt; does this actually tell me if it's blank?
Another C++ input question; cin and strings.?
word(4) will be whatever the default value for a vector is. You can't accept whitespace in cin, for that you need to use getline. However comparing word(4) == "" will tell if it is an empty string.
Also be careful with strings and characters:
" - for strings
' - for characters
Friday, July 31, 2009
Black Midget? George C.? Something Willis? HELP?
ok, there's this black midget that looks like a kid, excpet he has a mustache, and his name is george c-something i think. and his "catch-phrase" is something willis.
help please?
sorry this is completely random,
but it's bugging me!!!
Black Midget? George C.? Something Willis? HELP?
ummm, how about you think before you type. But 1st, ask mommy and daddy about mannerisms.
help please?
sorry this is completely random,
but it's bugging me!!!
Black Midget? George C.? Something Willis? HELP?
ummm, how about you think before you type. But 1st, ask mommy and daddy about mannerisms.
I met awonderful girl online, but lied to her bout me b/c all we wanted was cyber.How do I tell her the truth?
At 1st, we met in an AIM chatroom and were both looking for the same thing: an easy way to get off. I sent her a random picture of a goodlooking guy I found on the internet b/c I didn’t think she’d be attracted to me then.I never thought I’d talk to her again. We continued talking. We have developed a good friendship and more but basically I know she truly likes “me,” and I truly like her. These past few weeks it's been eating at me. It’s all I can think about, and it’s truly one of the things I regret the most in my life. I never wanted to hurt her, all I want is for our relationship to be honest. I have known her for long, there is no “trust” issue on my behalf of who she is, but she thinks I am someone I am not. She is truly one of the most wonderful people I have ever known, and I cannot bear the idea that I kept myself from her. I can’t keep up this lie.I want to know her in real life, we might be able to have something between us. I can't keep doing this. Somebody please help me
I met awonderful girl online, but lied to her bout me b/c all we wanted was cyber.How do I tell her the truth?
Tell her now before it gets worse. For all you know she could have done the same thing to you.
Why go through all this torment? You have to be true....it never works out when you lie......
Reply:You should always be honest from the very beggining or it will come back and hunt you. But your mistake is done, you must be honest with her and tell her the truth, the longer you wait the worst it gets. And if you did develop a good friendship she might be hurt but should understand due to the circumstances of your meeting. Be a man tell her now
Reply:Dude i fell into the trap too.....but the girl is all emo and its killing me.
Please!! for me.....man just dont get into it......itll tear you inside out and do it all again.....
It sucks like hell!!!
Reply:Woah, chill out for a sec...
Ok, so you sent her a pic of another guy. Yeah, bad move on your part- but in fact, if girl doesnt want to get to know you because of how you look, you deserve better, so never be afraid to show people who you are.
I guess at this point you still want to be friends. Let her know why you did it. If you have her number call her up. It sounds like you want to meet her or whatever, so thats what I'm basing this advice off of. If you arent goign to meet her, dont be selfish and tell her something you know is goign to hurt her so you can feel better about yourself.
Explain the situation to her. Let her know why you did it. Even show her this question if she doesnt believe you. Just let her know you are sorry. Hopefully if there is still something left after how you look, and you two really clicked, then she will still talk to you.
Good Luck
Reply:You basically just screwed yourself. This whole time she was thinking you were this good looking guy and when in reality you most likely aren't. If I were her and found out you were uglier than what I thought you actually looked like, I wouldn't want to talk to you anymore. Hopefully she is not at all superficial, and is VERY forgiving which is very unlikely.
Reply:No one is who they appear to be online...this shouldn't surprise you or her or anyone else in the World who's online. That's exactly why it's so tricky to meet someone online and think they're the most wonderful thing ever. It's all a fantasy, don't worry about it so much.
She knows nothing more about you then you know about her. How do you know her picture is truly her own??
Stick to meeting human beings...it's a wee bit safer, truly. If you want a long term, stable relationship...meet a human.
If you want fantasy...dream land...meet online, don't think it's true love or true anything.
Reply:y u lie to her if she is online now go and tell her truth plzz otherwise u'll loss her
Reply:Just come clean and tell her the truth, just be ready with the consequences.
I dont know man, at this exact time, maybe shes thinking of you as the gorgeous guy in the pic.
Good luck to you.
Reply:i think you have to tell her, there is no other way out, be honest and tell her what you've told us, its the only way, you just have to take that risk, and be earnest! make her believe that you have regretted it and fight for her if she gets angry with you, if you don't take the risk, you will be living with the lie and will probably never meet her, but if you do then you have the chance to find your soulmate. hope ive helped....xx
Reply:stop stringing the poor girl along.
tell her the truth ... NOW
Reply:Ask her if she'd still like you for your personality, regardless of looks. Then dump it on her. If she can't accept it, then she doesn't really care.
Reply:just tell her the truth. im pretty sure that your not the only person in the world that has sent someone a fake picture off the net. be honest with her she'll probably be upset at first but if she cares about you she'll forgive you good luck :)
Reply:Explain to her exactly what you explained on here. She'll understand and she herself probably did the same thing.
Reply:i have been in ur situation plenty of times before. just be honest and tell her what you told us. if she really wants to be with you and have a relationship then she will stick with you. but trusting u thereafter is gonna be pretty hard. she might keep thinking ur lying but u need to continually prove to her ur honesty thereafter. just trust me be honest and be upfront. and offer ur real info and ur real picture. if ur uncomfortable doing that then tell her so. just be honest and everything should be great!!!
Best of luck!!!
Reply:guess you'll find out what really matters to her...truth...show her the real deal...if she likes you for you it wont matter...unless she is shallow...
free survey
I met awonderful girl online, but lied to her bout me b/c all we wanted was cyber.How do I tell her the truth?
Tell her now before it gets worse. For all you know she could have done the same thing to you.
Why go through all this torment? You have to be true....it never works out when you lie......
Reply:You should always be honest from the very beggining or it will come back and hunt you. But your mistake is done, you must be honest with her and tell her the truth, the longer you wait the worst it gets. And if you did develop a good friendship she might be hurt but should understand due to the circumstances of your meeting. Be a man tell her now
Reply:Dude i fell into the trap too.....but the girl is all emo and its killing me.
Please!! for me.....man just dont get into it......itll tear you inside out and do it all again.....
It sucks like hell!!!
Reply:Woah, chill out for a sec...
Ok, so you sent her a pic of another guy. Yeah, bad move on your part- but in fact, if girl doesnt want to get to know you because of how you look, you deserve better, so never be afraid to show people who you are.
I guess at this point you still want to be friends. Let her know why you did it. If you have her number call her up. It sounds like you want to meet her or whatever, so thats what I'm basing this advice off of. If you arent goign to meet her, dont be selfish and tell her something you know is goign to hurt her so you can feel better about yourself.
Explain the situation to her. Let her know why you did it. Even show her this question if she doesnt believe you. Just let her know you are sorry. Hopefully if there is still something left after how you look, and you two really clicked, then she will still talk to you.
Good Luck
Reply:You basically just screwed yourself. This whole time she was thinking you were this good looking guy and when in reality you most likely aren't. If I were her and found out you were uglier than what I thought you actually looked like, I wouldn't want to talk to you anymore. Hopefully she is not at all superficial, and is VERY forgiving which is very unlikely.
Reply:No one is who they appear to be online...this shouldn't surprise you or her or anyone else in the World who's online. That's exactly why it's so tricky to meet someone online and think they're the most wonderful thing ever. It's all a fantasy, don't worry about it so much.
She knows nothing more about you then you know about her. How do you know her picture is truly her own??
Stick to meeting human beings...it's a wee bit safer, truly. If you want a long term, stable relationship...meet a human.
If you want fantasy...dream land...meet online, don't think it's true love or true anything.
Reply:y u lie to her if she is online now go and tell her truth plzz otherwise u'll loss her
Reply:Just come clean and tell her the truth, just be ready with the consequences.
I dont know man, at this exact time, maybe shes thinking of you as the gorgeous guy in the pic.
Good luck to you.
Reply:i think you have to tell her, there is no other way out, be honest and tell her what you've told us, its the only way, you just have to take that risk, and be earnest! make her believe that you have regretted it and fight for her if she gets angry with you, if you don't take the risk, you will be living with the lie and will probably never meet her, but if you do then you have the chance to find your soulmate. hope ive helped....xx
Reply:stop stringing the poor girl along.
tell her the truth ... NOW
Reply:Ask her if she'd still like you for your personality, regardless of looks. Then dump it on her. If she can't accept it, then she doesn't really care.
Reply:just tell her the truth. im pretty sure that your not the only person in the world that has sent someone a fake picture off the net. be honest with her she'll probably be upset at first but if she cares about you she'll forgive you good luck :)
Reply:Explain to her exactly what you explained on here. She'll understand and she herself probably did the same thing.
Reply:i have been in ur situation plenty of times before. just be honest and tell her what you told us. if she really wants to be with you and have a relationship then she will stick with you. but trusting u thereafter is gonna be pretty hard. she might keep thinking ur lying but u need to continually prove to her ur honesty thereafter. just trust me be honest and be upfront. and offer ur real info and ur real picture. if ur uncomfortable doing that then tell her so. just be honest and everything should be great!!!
Best of luck!!!
Reply:guess you'll find out what really matters to her...truth...show her the real deal...if she likes you for you it wont matter...unless she is shallow...
free survey
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.
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.
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.
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.
C probs..PLS HELP!!!!!!!?
how can i create a program that randomly add or subtract a number? example 3+2 or 10-3, i want the operation to be random...I already figure out the numbers, this is my only problem and that is to randomize the addition and subtraction operation...
btw the file extension is .c...tnx help you could help me... :)
C probs..PLS HELP!!!!!!!?
Im not that good in programming but i think you should get the ascii value for the operators and let the random function operate within those values. (not sure)
Reply:Have a random number between 0 and 1.
If 0 then add
else subtract.
Don't make it any more complicated.
btw the file extension is .c...tnx help you could help me... :)
C probs..PLS HELP!!!!!!!?
Im not that good in programming but i think you should get the ascii value for the operators and let the random function operate within those values. (not sure)
Reply:Have a random number between 0 and 1.
If 0 then add
else subtract.
Don't make it any more complicated.
C++ help!!!!!!!!!!!!!?
I have to make a programme in c++ in which a number is chosen randomly between 1 and 100. We type a number.
If it is less than the random no., it should display smaller;and if larger then bigger;if correct no. then the winner
Only 10 chances
Pleez help me
if u dont understand it IM me at aayushahuja2@yahoo.co.in
C++ help!!!!!!!!!!!!!?
int r=(rand()*100);
int input;
cin %26gt;%26gt; input;
if(input==r)
cout %26lt;%26lt; "You are winner" %26lt;%26lt; endl;
if %26lt;
cout %26lt;%26lt; "less" %26lt;%26lt; endl;
if %26gt;
cout %26lt;%26lt; "more"%26lt;%26lt;endl;
Reply:Enjoy doing your homework! Good luck getting someone to write it for you....!
survey results
If it is less than the random no., it should display smaller;and if larger then bigger;if correct no. then the winner
Only 10 chances
Pleez help me
if u dont understand it IM me at aayushahuja2@yahoo.co.in
C++ help!!!!!!!!!!!!!?
int r=(rand()*100);
int input;
cin %26gt;%26gt; input;
if(input==r)
cout %26lt;%26lt; "You are winner" %26lt;%26lt; endl;
if %26lt;
cout %26lt;%26lt; "less" %26lt;%26lt; endl;
if %26gt;
cout %26lt;%26lt; "more"%26lt;%26lt;endl;
Reply:Enjoy doing your homework! Good luck getting someone to write it for you....!
survey results
Subscribe to:
Posts (Atom)