当前位置:首页 > Software > C++ > 正文内容

一小时搞定C++_8

chanra1n6年前 (2019-11-05)C++5220
#include <iostream>
using namespace std;
int main()
{
	if(1+1==2)
	{	
		cout << "1+1=2";
	}
	else if(1+1==3)
	{
		cout << "1+1=3";
	}
	else
	{
		cout << "I Do not know!";
	}
	return 0;
}

if,顾名思义,就是如果的意思,它的用法非常简单:

if(条件)
{
    //如果条件成立就运行此处内容
}
else if(条件2)
{
    //如果条件2成立就运行此处内容
}
else
{
    //如果条件都不成立就运行此处内容
}


扫描二维码推送至手机访问。

版权声明:本文由我的FPGA发布,如需转载请注明出处。

本文链接:https://myfpga.cn/index.php/post/45.html

分享给朋友:

“一小时搞定C++_8” 的相关文章

C++ 中的变量类型创建和使用

C++ 中的变量类型创建和使用

      C++中需要掌握的只有int(整型)float (浮点)char (字符),其他的可自行百度后学习,但是基本上用不到      int float char 这三种类型,换成说人话的解释就是:   ...

数据类型及其占用空间

数据类型及其占用空间

#include<iostream> using namespace std; int main() { cout << "The size of int is&nb...

函数声明和使用

函数声明和使用

#include<iostream> using namespace std; int sum(int a,int b);//函数声明  int main() { cout <<&nb...

变量作用域

变量作用域

#include<iostream> void print(); int main() { char a=0; for(a=0;a<20;a++) print(); return 0;  }  v...