Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
724 B
1
Indexable
Never
#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    getline(cin,s);
    vector<string>tu;
    long long index=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]==' '&&s[i-1]==' ')
        {
            index=i+1;
        }
        if(s[i]==' '&&s[i-1]!=' ')
        {
            tu.push_back(s.substr(index,i-index));
            index=i+1;
        }
        if(i==s.size()-1)
        {
            tu.push_back(s.substr(index,s.size()-index));
        }
    }
    for(int i=0;i<tu.size();i++) 
    {
        if(tu[i][0]=='-') tu[i]="-1";
        else if(tu[i]!="0") tu[i]="1";
        cout<<tu[i]<<" ";
    }
    return 0;
}