- if(判断条件){执行语句}
#include<iostream> using namespace std; #include<string> int main() { int score = 0; cout << "Input your score,please :" << endl; cin >> score; cout << "Your score is " << score << endl; if (score >= 512) { cout << "You will own a good school!" << endl; } system("pause"); return 0; }
- if...else
#include<iostream> using namespace std; #include<string> int main() { int score = 0; cout << "Input your score,please :" << endl; cin >> score; cout << "Your score is " << score << endl; if (score >= 512) cout << "You will own a good school!" << endl; else cout << "see you next year" << endl; system("pause"); return 0; }
- 多种选择
#include<iostream> using namespace std; #include<string> int main() { float score = 0; cout << "Input students' score(0 to 100),please :" << endl; cin >> score; cout << "score is " << score << endl; if (score >= 90) cout << "The student' score is A" << endl; else if(score>=80) cout << "The student' score is B" << endl; else if (score >= 60) cout << "The student' score is C" << endl; else cout << "The student' score is D" << endl; system("pause"); return 0; }
原文链接: https://www.cnblogs.com/hackerteen/p/12375121.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍;
也有高质量的技术群,里面有嵌入式、搜广推等BAT大佬
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/332195
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!