2020.01-Study_update.2

2020 January 13

Second_week 1.13-1.19

- Study_update
Mon. whlie,do whlie①,break②
Tue.
Wed.
Thur.
Fri
Sat
Sun.

1.13 Monday

whlie

With whlie seeking elements of the array and

#include "pch.h"
#include <iostream>
using namespace std;
int sumit(int *parray_begin, int *parray_end);
int sumit(int *parray_begin, int *parray_end)
{
	int sum = 0;
	if (!parray_begin || !parray_end)
		return sum;
	while (parray_begin != parray_end)
		//把当前的值加到sum上
		//然后增加指针,使其指向下一个元素
		sum += *parray_begin++;
	return sum;
}
int main()
{
	
	int ia[3]{ 1,3,3 };
	cout<<sumit(begin(ia), end(ia))}

①do whlie

If the control loop is provided in the body of the loop, then use traditional whlie statement must set a value to start the cycle, using Do whlie statement to ensure the implementation of a cycle.

②break

break terminates recent while, do while, for, or switch statement. executive power of the program is passed to the statement immediately after the statement is terminated.

Released four original articles · won praise 0 · Views 87

Guess you like

Origin blog.csdn.net/weixin_46146882/article/details/103964745