摘要: 创建string对象#include <string>#include <iostream>using namespace std;int main(){ string s; cout<<s.length()<<endl; return 0;}/* 运行结果 0*/给sting对象赋值#include <string>#include <iostream>using namespace std;int main(){ string s; s ="2013 1 4"; cout<<s<& 阅读全文
posted @ 2013-01-05 14:29 about:blank 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 用 vector 向量容器装入十个整数#装入10个整数,然后用迭代器 iterator 和 accumulate 算法统计出这十个元素的和。#include <iostinclude <vector>#include <numeric> // accumulate需要using namespace std;int main(){ vector<int> v; int i; for (i=0; i<10; i++) { //尾部扩张方式赋值 v.push_back(i); } // 使用 iterator 迭代器顺序遍历所有元... 阅读全文
posted @ 2013-01-05 11:14 about:blank 阅读(227) 评论(0) 推荐(0) 编辑