26 lines
435 B
C++
26 lines
435 B
C++
|
// 嵌套分支
|
||
|
#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;
|
||
|
}
|