while语句语法:while(循环条件){循环语句}只要循环条件为真就会执行循环语句,直到不为真时退出循环#include <iostream>
#include<iomanip>
using namespace std;
i...
阅读全文...
C++-9-三目运算符和switch语句
三目运算符表达式1?表达式2:表达式3当表达式1为真时,执行并返返回表达式2,否则执行并返回表达式3#include<iostream>
using namespace std;
int main()
{
cout << ...
阅读全文...
阅读全文...
C++-8-if语句
单行if语句if (条件) {当条件为真时执行的语句}#include<iostream>
#include<cmath>
using namespace std;
int main() {
cout << &...
阅读全文...
阅读全文...
C++-6-数据的输入
关键字:cin语法cin>>变量#include<iostream>
using namespace std;
int main() {
int a = 0, b = 0;
cout << "...
阅读全文...
阅读全文...