This commit is contained in:
2026-03-03 13:25:15 +08:00
parent 109ed8def8
commit a84489c5de
2 changed files with 46 additions and 0 deletions

21
if逻辑判断语句.cpp Normal file
View File

@@ -0,0 +1,21 @@
//
// Created by violet on 2026/3/3.
//
#include "iostream"
using namespace std;
int main() {
/*
* if{}
*/
cout<<"今天发工资了"<<endl;
int money;
cout<<"请输入小明发的工资"<<endl;
cin>>money;
if (money>=10000) {
cout<<"小明去买电脑了"<<endl;
money -= 9900;
}
cout<<"小明工资还剩"<<money<<endl;
return 0;
}

25
三元运算符.cpp Normal file
View File

@@ -0,0 +1,25 @@
//
// Created by violet on 2026/3/3.
//
#include "iostream"
using namespace std;
int main() {
int num1,num2;
// while (true){
//
// cout<<"请输入num1的值"<<endl;
// cin>>num1;
// cout<<"请输入num2的值"<<endl;
// cin>>num2;
// string value = num1>num2?"num1>num2":"num1<=num2";
// cout<<value<<endl;
//
// }
cout<<"请输入小明第一次考试的成绩(0-100):"<<endl;
cin>>num1;
cout<<"请输入小明第二次考试的成绩(0-100):"<<endl;
cin>>num2;
cout<<"对小明的考试成绩进行判断,结果是:"<<(num1<num2?"买糖":"不买糖")<<endl;
return 0;
}