qfedu-basic-level/day7/d4.cpp

26 lines
435 B
C++
Raw Normal View History

2023-06-21 14:30:56 +08:00
// 嵌套分支
#include <iostream>
using namespace std;
int main()
{
int n;
cout << "请输入一个整数: ";
cout << "请输入一个整数: ";
cin >> n;
if (n % 3 == 0 || n % 5 == 0)
{
// n 能被 3 或 5 整除
if (n % 3 == 0)
cout << "Fizz";
if (n % 5 == 0)
cout << "Buzz";
cout << endl;
}
else
cout << n << endl;
return 0;
}