C++——绪论到简单变量

#include<iostream>
using namespace std;
int main()
{
	cout << "Come up and C++ me some time.\n";
	cout << "YOu won't regret it.!" << endl;
	return 0;
}

        通常,C++函数可被其他函数激活或调用,函数头阐明了函数与调用他的函数之间的接口。位于函数名前面的部分叫做函数返回类型,函数名后面的部分叫做形参列表。可使用int main(void)或void main()作为开头

#include<iostream>
using namespace std;
 int main(void)
{
	cout << "Come up and C++ me some time.\n";
	cout << "YOu won't regret it.!" << endl;
	return 0;
}
#include<iostream>
using namespace std;
 void main()
{
	cout << "Come up and C++ me some time.\n";
	cout << "YOu won't regret it.!" << endl;
}

        using叫做编译指令。简单来说,没加之前使用cout需要写为std::cout<<"Hello World".使用之后可省略std。

变量名:

        1、在名称中只能使用数字、字母、字符和下划线。

        2、名称的第一个字符不能是数字。

        3、区分大写字符和小写字符。

        4、不能将关键字作为名称。

        进制的转换

#include<iostream>
using namespace std;
 int main()
{
	 int chest = 42;
	 int waist = 42;
	 int inseam = 42;
	 cout << "chest =" << chest << " (decimal for 42)" << endl;
	 cout << hex;
	 cout << "waist =" << waist << " (hexadecimal for 42)" << endl;
	 cout << oct;
	 cout << "inseam =" << inseam << " (octal for 42)" << endl;
	 return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值