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

More than 1 year has passed since last update.

多言語FizzBuzzAdvent Calendar 2022

Day 6

多言語FizzBuzzチャレンジ6日目:C++

Last updated at Posted at 2022-12-05

これまでのまとめ

本日のお品書き

泣く子も黙る(再)C++。FizzBuzzするだけならCと大きくは違わないですね…。

FizzBuzz

#include <iostream>
// iostreamの中で定義している`std`名前空間を呼び出している
// std::cout, std::endl などを短縮して呼び出すため
using namespace std;

int main() {
  for (int i = 0; i < 101; i++) {
    if (i % 15 == 0) {
      cout << "FizzBuzz" << endl;
    } else if (i % 3 == 0) {
      cout << "Fizz" << endl;
    } else if (i % 5 == 0) {
      cout << "Buzz" << endl;
    } else {
      cout << i << endl;
    }
  }
  return 0;
}

【おまけ】コンパイルまで

g++ main.cpp
./a.out
0
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
0
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?