7336人加入学习
(18人评价)
C++编程系列 第一季编程基础

制作于2018年2月7日

价格 免费

初始化

do{

 

}while(判断);

 

int scores[]={123,5,6,8,4,25,69}

for(int temp:scores){

cout<<temp;scores

}

for 使用定义临时变量temp 读取数组里的每个yuan's

[展开全文]

do{循环体} while(判断)  while先执行判断  

 

do先执行循环体

[展开全文]

C++11的新遍历方式:

for(int 临时变量 : 数组)

{

}

 

#include <iostream>

using namespace std;

int main()

{

//do {

// // 循环体

//} while (判断);

 

int i = 100;

//do

//{

// cout << "创建敌人" << endl;

//} while (i>100);

// do while 循环体次数 >=1 的

 

//while (i>100)

//{

// cout << "创建敌人" << endl;

//}

// while 循环体次数 >=0 的

 

int scores[] = { 234,2,42,3,2,42,42,32 };

//for (int i = 0; i < 8; i++)

//{

// cout << scores[i] << endl;

//}

 

// C++11的标准

//for (int temp : scores)

//{

// //cout << temp << endl;

// temp = 10; // 笔记:不起作用

//}

//for (int temp : scores)

//{

// cout << temp << endl;

//}

 

 

for (int& temp : scores) // 注意:int& temp

{

//cout << temp << endl;

temp = 10;// temp = temp * 2; // 起到作用了,因为 int & temp,引用类型

}

for (int temp : scores)

{

cout << temp << endl;

}

 

return 0;

}

[展开全文]

授课教师

SiKi学院老师

课程特色

下载资料(1)
视频(58)