Author: Anurag
Tester: Anurag
Editorialist: Anurag
DIFFICULTY:
EASY,MEDIUM,GREEDY,STRING,CAKEWALK, SIMPLE
PREREQUISITES:
Math ,String
PROBLEM:
Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.
Note, that during capitalization all the letters except the first one remains unchanged.
EXPLANATION:
In above example we have given a word and we have to simply check the first letter of the word if the first letter is lowercase letter then we have to change it to upper case letter and print it
for example:
anurag
in above string first letter is lowercase letter then we have to change it to uppercase letter and print the rest string
so the output is Anurag
SOLUTIONS:
Setter's Solution
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void testcase()
{
cin>>ws;
string s;
cin>>s;
//int i=0;
if((s[0]>=‘a’) &&(s[0]<=‘z’)){
s[0]-=32;
cout<<s;
}
else
cout<<s;
}
int main()
{
int t;
cin>>t;
while(t–)
{
testcase();
cout<<endl;
}
return 0;
}
Tester's Solution
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void testcase()
{
cin>>ws;
string s;
cin>>s;
//int i=0;
if((s[0]>=‘a’) &&(s[0]<=‘z’)){
s[0]-=32;
cout<<s;
}
else
cout<<s;
}
int main()
{
int t;
cin>>t;
while(t–)
{
testcase();
cout<<endl;
}
return 0;
}
Editorialist's Solution
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void testcase()
{
cin>>ws;
string s;
cin>>s;
//int i=0;
if((s[0]>=‘a’) &&(s[0]<=‘z’)){
s[0]-=32;
cout<<s;
}
else
cout<<s;
}
int main()
{
int t;
cin>>t;
while(t–)
{
testcase();
cout<<endl;
}
return 0;
}