vector
vector可以保存给定类型的一连串的值,为了容纳新的值,vector可以根据需要来增加长度。
一个单独的vector包含的所有值都是同一类型的,但是不同的vector可以包含不同类型的对象
格式:
vector<double> homework //定义vector时要申明变量类型
homework.push_back(x) //添加数据
实际应用中的程序:
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
using namespace std;
int main()
{
cout << "please input your first name: ";
string name;
cin >> name;
cout << "Hello, " << name << "!" << endl;
cout << "Please enter your midterm and final exam grades: ";
double midterm, final;
cin >> midterm >> final;
cout << "Enter your homw work grades,"
"followed b