0
I need to make a program in C that takes a sequence of numbers, stores the values in a vector and then prints this sequence in the reverse order. It must receive two entries, the first is an integer number indicating how many numbers the sequence has, and the second is the sequence of numbers (each number is separated only by a 'blank space'), as follows in the example:
4
2 51 8 10
To read the string I thought to use the function:
char sequencia[100];
scanf("%[^\n]",sequencia);
However I am not able to separate the values and store inside an integer vector. How can I solve this problem?
Why read as string ? use scanf("%d")
– Felipe
using scanf(%d) how do I have each value stored in a different position? Obs: the sequence is passed to the program in a single string, each value is separated by a 'space' only
– ongaku
is it mandatory that the numbers are separated by spaces? The numbers could not be typed separately?
– Eduardo Mendes
Create an array of size 100 (I’m assuming 100 because Voce used the size of your string) for int values ... and use a;
– Felipe
the question asks that they be separated by spaces only, the only way I thought of doing this was to read as a string and separate the values using space as delimiter
– ongaku