第一章以及第二章

1.cout 输出函数,存在于c++中iostream的文件中。
(cout 可用于字符串和数字)
2.控制符 endl 表示:重起一行。
3.cin输入函数。

#include <iostream>

int main()
{
	using namespace std;//访问位于名称空间std中的cout定义。
	int a;
	cin >> a;
	cout << "a:";
	cout << a<<endl;
	return 0;
}

4.变量必须要声明。
5.类的简介
类就是用户定义的一种数据类型。
类描述指定了可对类对象执行的所有操作。
6.c++不允许将函数定义嵌套在另一个函数定义中。每个函数定义都是独立的,所有函数的创建都是平等的。
练习题:

#include <iostream>
using namespace std;
void shu();
void shu2();
int main()
{
	int i;
	for(i=0;i<2;i++)
	{
		shu();
	}
	for (i = 0; i < 2; i++)
	{
		shu2();
	}
	return 0;
}

void shu()
{
	cout << "Three blind mice!"<<endl;
}

void shu2()
{
	cout << "See how they run"<<endl;
}
#include <iostream>
using namespace std;
int main()
{
	int age,month;
	cout << "Enter_your age:";
	cin >> age;
	month = age * 12;
	cout << month<<endl;
	return 0;
}
#include <iostream>
using namespace std;
void shu(int, int);
int main()
{
	int min, hour;
	cout << "输入小时数:";
	cin >> min;
	cout << "输入分钟数:";
	cin >> hour;
	shu(min, hour);
	return 0;
}

void shu(int min, int hour)
{
	cout << "Enter the number of hours:"<<min<<endl;
	cout << "Enter the number of minutes:" << hour << endl;
	cout << "Time:" << min << ":" << hour << endl;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值