Quantcast
Channel: プログラミング
Viewing all articles
Browse latest Browse all 8071

【AtCoder】ABC 335 A - 2023 | 茶コーダーが解くAtCoder - Yuulis.log

$
0
0

atcoder.jp

実行時間制限: 2 sec / メモリ制限: 1024 MB / Difficulty: 9

問題概要

英小文字と数字からなる文字列  Sが与えられる。ただし、  S2023で終わることが保証される。  Sの最後の文字を4に変更した文字列を出力せよ。

制約

  •  Sの長さは  4以上  100以下。

考察

 Sの文字への参照をするには、S.back()を使うのが最も簡単だ。これを用いて末尾の文字を4へ置換しよう。

コード

#include <bits/stdc++.h>usingnamespacestd;

// ======================================== //intmain()
{
    string S;
    cin>> S;

    S.back() = '4';

    cout<< S << endl;

atcoder.jp

実装時間: 5分以内


Viewing all articles
Browse latest Browse all 8071

Trending Articles