ABC 126 Editorial¶
Problem A: Changing a Character¶
The key here is to print all the characters as they are, and change the one at index k-1. This character will be lowercased. We will use C++ lowercase function to achieve this. Code is below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include<bits/stdc++.h>
using namespace std;
int main () {
int n, k;
string s;
cin >> n >> k >> s;
for (int i=0; i< n; i++) {
if (i == k-1) putchar( tolower(s[i]) );
else putchar(s[i]);
}
return 0;
return 0;
}
|