問題一覧
お問い合わせ
light_mode
dark_mode
2倍を繰り返す (while文) (C++)
問題
上限を読み込み、while 文で1から2倍ずつ増やした数を上限以下の間表示するプログラムです。
入力例
100
出力例
1 2 4 8 16 32 64
スタート
残り時間:
00:00
速度:
0
文字/分
参照コード
コピーはできません。自分でタイピングしてください。
#include <iostream> using namespace std; int main() { int limit; int x = 1; cin >> limit; while (x <= limit) { cout << x << endl; x *= 2; } return 0; }
入力エリア
コンパイル&実行
3