c_cpp foundational_programming-CPP-length1.cpp

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp foundational_programming-CPP-length1.cpp相关的知识,希望对你有一定的参考价值。

#include <iostream>  // std::cout, std::endl
#include <vector>    // std::vector

using std::cout;
using std::endl;
using std::vector;

int length(vector<double> &x) {
	int out = 0;

    for (auto it = begin(x); it != end(x); ++it) {
        out++;
    }

	return out;
}

int main() {
    vector<double> v{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
    
    int result = length(v);
    
    cout << "length: " << result << endl;
    
    return 0;
}

//> length: 20

以上是关于c_cpp foundational_programming-CPP-length1.cpp的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp 127.单词阶梯

c_cpp MOFSET

c_cpp MOFSET

c_cpp 31.下一个排列

c_cpp string→char *

c_cpp 54.螺旋矩阵