以下の内容はhttps://shiroyuki2020.hatenablog.com/entry/atcoder_abc051_aより取得しました。


AtCoder|ABC051:A - Haiku

AtCoderの過去問対策です。ABCで解けなかった問題、ためになった問題のコードを備忘録として残します。

問題

A - Haiku

解説

https://img.atcoder.jp/abc051/editorial.pdf

解答例1

#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;
  
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == ','){
      s.at(i) = ' ';
    }
  }
  cout << s << endl;
}

メモ

  • 全ての文字を調べて、カンマをスペースに変換する

解答例2

#include <bits/stdc++.h>
using namespace std;

int main(){
  string s;
  cin >> s;
  s.at(5) = ' ';
  s.at(13) = ' ';
  cout << s << "\n";
}

メモ

  • 変換する位置は決まっているので、ピンポイントで変換する




以上の内容はhttps://shiroyuki2020.hatenablog.com/entry/atcoder_abc051_aより取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14