⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exe3.13 suboptimal.cpp

📁 C++ primer 4th edition 部分习题解答 前十章
💻 CPP
字号:
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main()
{
	vector <int> vec1,vec2;
	bool isEnd=false;
	for (vector<int>::size_type xi=0;xi!=11;xi++)
	{
		vec1.push_back(xi*10+10);
	}
	
	for (vector<int>::size_type xi=0;xi<=vec1.size();xi+=2)
	{
		if (xi+1==vec1.size())
		{
			cout<<vec1[xi]<<endl<<"That's the end."<<endl;
			isEnd=true;
		}
		else
		{
			cout<<vec1[xi]+vec1[xi+1]<<endl;
		}
	}
	if (!isEnd)
	{
		cout<<"That's the end."<<endl;	
	}
	
	for (vector<int >::size_type xl=0,xr=vec1.size()-1;xl<xr;xl++,xr--)
	{
		if (xl+1==xr)
		{
			cout<<"That's the end."<<endl;
			isEnd=true;
		}
		else
		{
			cout<<vec1[xl]+vec1[xr]<<endl;
		}	
	}
	
	if (!isEnd)
	{
		cout<<"That's the end."<<endl;	
	}
	cout<<vec1.size()<<endl;
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -