By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,134 Members | 1,742 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,134 IT Pros & Developers. It's quick & easy.

how can i input several numbers in the same line?

P: 7
hi im the beginner of the c++ ...how can i build the programm so that in the output box i can input a number n in the first line and in the second line i input n numbers on the same line with a space in between each number next to it..and the output will displayed the same numbers that i have entered but in a reverse way with space in between the each number next to it..
for example..
input: 5
2 1 4 3 6

output: 6 3 4 2 1
Nov 8 '06 #1
Share this Question
Share on Google+
1 Reply


sicarie
Expert Mod 2.5K+
P: 4,677
hi im the beginner of the c++ ...how can i build the programm so that in the output box i can input a number n in the first line and in the second line i input n numbers on the same line with a space in between each number next to it..and the output will displayed the same numbers that i have entered but in a reverse way with space in between the each number next to it..
for example..
input: 5
2 1 4 3 6

output: 6 3 4 2 1
It sounds like you need to use 'getline()' to read them into an array, and then output the array from last to first.

Here is a bit of reading on getline():
http://www.codecomments.com/archive2...-1-377516.html

And here is a bit on the intro stuff, if you need help with arrays:
http://www.informit.com/articles/art...p?p=25281&rl=1

There's a place for you to start. Feel free to post more when you have it.
Nov 8 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.