1 //26-do while loop. CPP: The entry point that defines the console application. 2 //3 4#include"stdafx.h"5#include <iostream>6#include <climits>7#include <array>8#include <string>9 using namespacestd;Ten One intMain () A { - //Do { - //Loop Body the //} while (judgment); - - inti = -; - Do { +cout <<"Create Enemies"<< Endl;//run after the judgment, only executed once. -} while(i> -); + A while(i> -) at { -cout <<"Create Enemies"<< Endl;//after the judgment is executed, no code is executed. - } - - //While execution is greater than or equal to 0,do while the number of executions is greater than 1. - in //simple traversal of an array with a For loop - intScores[] = { the,245,6, the,742,3,763, A,}; to for(intI=0;i<8; i++) + { -cout << Scores[i] <<Endl; the } * $ //c++11 Simple way to iterate through an arrayPanax Notoginseng for(intTemp:scores)//can only take temp corresponding value, cannot set value, if need to set temp corresponding value, write (int& temp:scores) - { the //cout << Temp * 2 << Endl;//no effect. All values in the array have not changed. +cout << Temp <<Endl; A } the + for(int& Temp:scores)//Adding & indicates that temp is a reference in each array, and with this reference you can modify the corresponding value in temp. - { $cout << Temp *2<< Endl;//All the values in the array are enlarged by twice times! $ } - - the intT; -CIN >>T;Wuyi return 0; the}
C + + Programming basics a 26-do while loop