for循环

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main ()
{
    //   第一部分; 条件;表达式 
	for(int i = 0; i < 10; ++i)
	{
         cout << i;
		 cout << endl;

	}
    
	vector<string> svec;
	svec.push_back("I");
	svec.push_back("LOVE");
	svec.push_back("C++");

	for(vector<string>::size_type ind = 0; ind != svec.size(); ++ind)
	{
         cout << svec[ind] << " ";
	}
	 cout << endl;


	 const int size = 10;
	 int val = 0, ia[size] = {0,1,2,3,4,5,6,7,8,9};
	 int *pi = ia;  // 声明一个指针,
	 int &ri = val; //声明一个引用,
	 for(int ival = 0; ival != size; ++ival)
	 {
        cout << ia[ival] << ", " << ia[ri] << ", " << ia[val] << ", " << *pi << endl;
		++pi;
		++ri;
	 }

	return 0;
}

你可能感兴趣的:(for循环)