Official

A - 202<s>3</s> Editorial by en_translator


For beginners

There are several ways to change the last character 3 of a string \(S\) to 4:

  • Print all but last characters of \(S\), and then print 4.
  • Remove the last character of \(S\), insert 4 to its tail, and print the resulting string.

Recheck how to handle strings (or arrays etc. corresponding to strings) in your language before implementing.

Sample code (Python):

s = str(input())
l = len(s)
for i in range(l-1):
  print(s[i],end="")
print("4")

Sample code (C++):

#include<bits/stdc++.h>

using namespace std;

int main(){
  string s;
  cin >> s;
  s.pop_back();
  s.push_back('4');
  cout << s << "\n";
  return 0;
}

posted:
last update: