Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

input numbers to int c++

#include <iostream>
#include <vector>
#include <sstream>
using namespace std;
int main()
{
    vector< int >arr;
    string input;
    getline(cin, input);
    istringstream is(input);
    int num;
    char c;
    while(true)
    {
        is>>num;
        arr.push_back(num);
        if(!is.eof()) is>>c;
        else break;
    }
    for(int x: arr)
    cout<< x <<" ";
}
Source by discuss.codechef.com #
 
PREVIOUS NEXT
Tagged: #input #numbers #int
ADD COMMENT
Topic
Name
6+8 =