zoukankan      html  css  js  c++  java
  • Exercice_3.13.1_练习使用vector2

    //读取一组整数到vector 并计算头尾元素的和
    #include <iostream>
    #include <vector>
    using namespace std;
    
    int main()
    {
        vector<int> ivec;
        int ival;
    
        //读取整数
        cout << "Enter numbers(Ctrl+Z to end)." << endl;
        vector<int>::size_type first, last;
    
        while (cin >> ival)
            ivec.push_back(ival);
    
        //计算首尾元素之和
        if (ivec.size() == 0)
            cout << "No elements.?!" << endl;
    
        for (first = 0, last = ivec.size() - 1; first < last; ++first, --last)
            cout << ivec[first] + ivec[last] << "	";
    
        if (first == last)
            cout << "The middle element is not summed and it's value:" << ivec[first] << endl;
        return 0;
    }
    

  • 相关阅读:
    DRF
    DRF
    DRF
    DRF
    DRF
    DRF
    DRF
    Mongo错误记录:MongoClient opened before fork. Create MongoClient
    Hive默认分隔符和默认NULL值
    hdfs文件格式比较
  • 原文地址:https://www.cnblogs.com/mrbourne/p/9959475.html
Copyright © 2011-2022 走看看