79645118

Date: 2025-05-30 08:26:05
Score: 0.5
Natty:
Report link

Space separated String int -> vector<int> Mini

#include <sstream>

int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    int n;
    cin >> n;
    cin.ignore();
    
    vector<int> nums;
    string input;
    getline(cin, input);
    
    stringstream ss(input);

    int temp1;
    // Extract integers from the stringstream and add them to the vector
    while (ss >> temp1) {
        nums.push_back(temp1);
    }
    
    for(int num : nums){
        cout << num << " ";
    }
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: user30431269