Untitled

 avatar
user_2773531
plain_text
a year ago
803 B
1
Indexable
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
string capitalizeTitle(string title) {
        int c=0,idx=0;
        for(int i=0;i<title.size();i++)
        {
            title[i]=tolower(title[i]);
        }
        for(int i=0;i<title.size();i++)
        {
            if(title[i] != ' '){
                ++c;
                if(c == 1){
                    idx = i;
                }
            }
            if(title[i]==' ' || (i+1)==title.length())
            {
                if(c > 2)
                {
                    title[idx]=toupper(title[idx]);
                }
                c=0;
            }
        }
        return title;
    }
    
    int main()
    {
        string s;
        getline(cin,s);
        cout<<capitalizeTitle(s);
        return 0;
    }