1#include <bits/stdc++.h>
2using namespace std;
3
4int main() {
5 int a, b, c;
6 cin >> a >> b >> c;
7 if (a + b > c) {
8 cout << "yes" << endl;
9 } else {
10 cout << "no" << endl;
11 }
12 return 0;
13}1#include <bits/stdc++.h>
2using namespace std;
3
4int main() {
5 int a, b, c;
6 cin >> a >> b >> c;
7 if (a + b > c && a + c > b && b + c > a) {
8 cout << "Yes" << endl;
9 } else {
10 cout << "No" << endl;
11 }
12
13 return 0;
14}1#include <bits/stdc++.h>
2using namespace std;
3
4int main() {
5 int n;
6 cin >> n;
7 if (0 == n % 2) {
8 cout << "2" << endl;
9 }
10 if (0 == n % 3) {
11 cout << 3 << endl;
12 }
13 if (0 == n % 5) {
14 cout << 5 << endl;
15 }
16 if (0 == n % 7) {
17 cout << 7 << endl;
18 }
19 return 0;
20}条件控制流程图会包含带有条件判断的分支结构。
if-else结构会检查一个条件,如果为真则执行if后的代码,如果为假则执行else后的代码。
if (布尔表达式) {
操作1
} else {
操作2
}1int number = 10;
2if (number > 0) {
3 cout << "Number is positive." << endl;
4} else {
5 cout << "Number is not positive." << endl;
6}