AtCoderをやってみたい。
自分の欲しいものを作りたくてプログラミングを勉強しているが、競技プログラミングは部活みたいでなんか面白そう。
少し前から興味を持っていたけど、Webサイトを見てもよくわからなかった。
しかし、AtCoderの書籍が出たのでスタートは切れそう。
私はプログラミング初心者なので、AtCoderの基本の基本である入力方法をすぐに忘れてしまう。
すぐに思い出せるようにメモします。
Pythonでの入出力
1つの数字の入出力
a = int(input()) # 1
2つ以上の場合
b,c = map(int,input().split()) # 1 2
リストでの入出力
d = list(map(int,input().split())) # [1, 2, 3, 4, 5]
ほぼこの3つで対応できると思います。
あと、たまにあるのが文字列として入力する場合があります。
a = str(input()) # 123
その場合は、strを使います。
C++での入出力
1つの数字の入出力
#include <bits/stdc++.h> using namespace std; int main() { int A; cin >> A; cout << A << endl; }
2つ以上の場合
#include <bits/stdc++.h> using namespace std; int main() { int A,B; cin >> A >> B; cout << A << B << endl; }
ちなみに、C++を練習するときはVisual Studioを使っています。
デフォルトでは「using namespace std;」がないので、以下のように「std::」を付けてます。
#include <iostream> int main() { int A,B; std::cin >> A >> B; std::cout << A << B << std::endl; return 0; }
AtCoderについてのメモはここに追記してきます。