【C++学习】vector的使用,输入一串数字,输出相邻和---ShinePans
2014-02-04 14:25
330 查看
/* *连续使用cin输入,输入进vector,输入一串数字,输出相邻和 */ #include <iostream> #include <string> #include <vector> #include <cctype> using std::vector; using std::string; using namespace std; int main() { int ivec_temp, temp; //////////定义矢量的临时对象量 vector<int> ints; //////////定义string 类型的矢量 cout << "Input sentences,I will change it to UPPER!" << endl; while (cin >> ivec_temp) /////////输入定量的字符串 ints.push_back(ivec_temp); ////////////注入ivec矢量 /////////////遍历vector///////////////////////////////////////// for (int index = 0; index < (ints.size())-1; index++) { temp = ints[index] + ints[index + 1]; cout << temp; } system("pause"); return 0; }
相关文章推荐
- 【C++学习】vector的使用,输入小写,输出大写---ShinePans
- 【C++学习】迭代器的使用:vector的操作---ShinePans
- [c++学习] dowhile 输入两个string ,判断较大的.---ShinePans
- [c++的运用]-使用迭代器,vector指针统计分数---ShinePans
- 【C++学习】-字符串转为数字,数字转为字符串(sstream)---ShinePans
- python 循环语句while的使用——两种方法输出用户输入的数字
- C++学习之cout如何控制输出数字的精度
- C++学习笔记之输入和输出
- C++ Primer高速学习 第一章 获得二:输入和输出 (IO)
- C++学习_IO:输入/输出
- C++学习 【3.2】 程序设计初步---输入、输出&关系运算、逻辑运算
- 输入一串数字 以此加空格输出
- 读一组整数到vector对象,计算并输入每对相邻元素的和,如果读入元素个数为奇数,则提示用户最后一个元素没有求和,并输出其值。
- Arduino学习笔记之Arduino的数字输出&串口输入
- C++ 计166-1 C语言实验——输入数字星期,输出英文(选择结构-switch)
- C++代码札记(二)猴子吃桃问题、输入10个数字,输出其中最大的3个数字。
- C++学习笔记:文件输入和输出
- c++入门:输入一个字符串,将其分段输出,分段符为除字母和数字之外的符号。
- C++ 入门教程(五) 使用 std::cout 输出和数字分位符的使用
- C/C++学习(二)输入n个整数,输出其中最小的k个。