TOPIC

wrong error 5%

Lucas Brandão asked 1 year ago

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main(){
    int n;
    string str;
    cin >> n;
    cin.ignore();
    int sensor = 0;
    for(int i = 0; i < n; i++){
        getline(cin, str);
        for(int j = 0; j < str.length(); j++){
            if(str[j] != ' ' && sensor == 0){
                cout << str[j];
                sensor = 1;
            }
            if(str[j] == ' ')
                sensor = 0;
        }
        cout << endl;
    }
}

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.