天天看點

C++Primer3.4.1練習題。

#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <algorithm>
using namespace std;

int main()
{
	
	vector<string> text(3, "csdn");
	for (auto it = text.cbegin(); it != text.cend()/* && !isspace(*it)*/; it++)
	{
		cout << "size:" << it->size() << endl;
		cout << *it << endl;
	}

	string texts("csdn is a pretty station.");
	for (auto it = texts.begin(); it != texts.end(); ++it)
	{
		*it = toupper(*it);
		cout << *it;
	}

	vector<int> doubleContent = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
	for (auto it = doubleContent.begin(); it != doubleContent.end(); ++it)
	{
		cout << "Before:"<<(*it);
		*it = (*it) * 2;
		cout << " After:" << (*it) << endl;
	}
	getchar();
	return 0;
}
           

日夜,日夜,日日夜夜。