Hola quisiera saber como eliminar o evitar el ultimo ciclo de un for, ya que cuando se ejecuta el for añado comas para detallar la separacion de elementos y al realizar el ciclo se al final se agrega la coma.
#include <iostream>
#include <vector>
using namespace std;
int main() {
int size_vector = 0;
// Declaring a size vector
cout << "Size of the vector: "; cin >> size_vector;
// Printing a vector size warning.
cout << "Your vector need to have " << size_vector << " elements" <<endl;
vector <int> vector_container (size_vector); //Declaring the vector container
cout << "Insert values : ";
for(int iterator = 0; iterator < size_vector; iterator++) {
cin >> vector_container.at(iterator); //Iterating the input by stored in vector
}
cout << "Vector elements: ";
for(int iterator = 0; iterator < size_vector; iterator++) {
cout << vector_container.at(iterator) << ", "; //Iterating vector's elements.
}
}
Ejemplo de consola:
Size of the vector: 3
Your vector need to have 3 elements
Insert values : 1 2 3
Vector elements: 1, 2, 3,
DEL RESULTADO "VECTOR ELEMENTS: " QUISIERA ELIMINAR LA ULTIMA COMA.