IF语句
单行if语句
#include<iostream>
using namespace std;
int main()
{
int score = 0;
cout << "输入分数:" << endl;
cin >> score;
cout << "输入的分数为:" << score << endl;
if (score > 600)
{
cout << "恭喜" << endl;
}
system("pause");
return 0;
}
多行、多条件、嵌套if语句
#include<iostream>
using namespace std;
int main()
{
int score = 0;
cout << "输入分数:";
cin >> score;
cout << "输入的分数为:" << score << endl;
if (score > 600)
{
if (score > 650)
{
cout << "nb" << endl;
}
else
{
cout << "恭喜" << endl;
}
}
else if(score>500)
{
cout << "no" << endl;
}
else
{
cout << "nonono" << endl;
}
system("pause");
return 0;
}