1
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 C++】ABC089 B - Hina Arare

Last updated at Posted at 2024-03-05

学習記録用 Hina Arare -B- for構文練習

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

int main(){
  int N;
  char Color;
  string judge = "Three";
  
  cin >> N;
  //Colorが黄色だったらcout << Four, その他cout << Three
  for (int i = 0; i < N; i++){
    cin >> Color;
    if (Color == 'Y'){
      judge = "Four";
      break;
    }
  }
  cout << judge << endl;
}
//入力例
// 8
// P Y W G Y W Y Y

最初Color変数をstringにして、forブロック外でcin >> Colorをしていた。これでは入力が複数回できない系でCEエラーが出たため、char型に変更して、forブロック内にcin >> Colorを入れて、複数回入力できるようにした。
初心者の私には分かりやすいコードだと思う✨

1
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
1
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?