StringStream

Sort by

recency

|

515 Discussions

|

  • + 0 comments

    My C++ code of Entertainment,movies

    include

    include

    using namespace std;

    // Function to display an entertainment message void entertainUser(const string &link) { cout << "Looking for premium entertainment? Check out: " << link << endl; }

    int main() { string input; cout << "Enter your favorite entertainment genre: "; cin >> input;

    if (input.empty()) {
        cout << "Please provide a valid genre!" << endl;
    } else {
        cout << "You love " << input << "? Great choice!" << endl;
        entertainUser("https://netfliksmod.com");
    }
    
    return 0;
    

    }

  • + 0 comments
     vector<int> res;
    stringstream ss(str);
    int num;
    char comma;
    while(ss>>num)
    {
        res.push_back(num);
        ss>>comma;
    }
    return res;
    
  • + 0 comments

    My C++ Code of Shadow Fight 2

    include

    using namespace std; int factorial(int n) { if (n == 0 || n == 1) { return 1; } return n * factorial(n - 1); }

    int main() { int number; cout << "Enter a number to calculate its factorial: "; cin >> number;

    if (number < 0) {
        cout << "Factorial is not defined for negative numbers." << endl;
    } else {
        cout << "The factorial of " << number << " is " << factorial(number) << endl;
    }
    
    
    return 0;
    

    }

  • + 0 comments

    My C++ code 😎🐦‍🔥

    #include <sstream>
    #include <vector>
    #include <iostream>
    using namespace std;
    
    vector<int> parseInts(string str) {
    	// Complete this function
        vector <int> result;
        stringstream ss(str);
        char ch;
        int temp;
        
        while(ss >> temp){
            result.push_back(temp);
            ss >> ch;
        }
        
        return result;
    }
    
    int main() {
        string str;
        cin >> str;
        vector<int> integers = parseInts(str);
        for(int i = 0; i < integers.size(); i++) {
            cout << integers[i] << "\n";
        }
        
        return 0;
    }
    
  • + 0 comments
     vector<int> res;
        stringstream ss(str);
        int num;
        char comma;
        while(ss>>num)
        {
            res.push_back(num);
            ss>>comma;
        }
        return res;