0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[AtCoder備忘録記事]AtCoder Beginner Contest 339 A問題

Posted at

AtCoder Beginner Contest 339 A問題
こちらの問題です。

問題

image.png

入出力例

image.png

解法

std::stringのfind_last_ofメソッドを使うと、特定の文字の最後の出現位置を簡単に見つけることができます。
見つけた後にそれ以降の文字列を出力して終了です。

#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <cmath> 
#include <algorithm>
using namespace std;

int main() {
    string S;
    cin >> S;
    size_t pos = S.find_last_of('.');
    if (pos != string::npos)
        cout << S.substr(pos + 1) << endl;
    else
        cout << "" << endl;
    return 0;
}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?