yokobuttonの不定期で競技プログラミングをするブログ

不定期で解けた競技プログラミングコンテストの問題を載せています。

AtCoder Beginner Contest 244 A - Last Letter

問題の要約
 英小文字からなる長さNの文字列Sが与えられる。Sの末尾の文字を出力せよ。
制約
 1<=N<=1000
入力
 N
 S
考え方
 1,c++の場合、文字列をstringで受け取って、N-1の文字を出力する。

実際のプログラム
#include<iostream>
#include<string>

using namespace std;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  cout << S[N-1] << endl;
  return 0;
}