C++ List size()函数查找列表中存在的元素数。此函数不会修改双端队列的内容。
int size();
它返回列表中的元素数。
让我们看一个简单的例子
#include <iostream> #include<list> using namespace std; int main() { list<int> li={1,2,3}; std::cout << "size of the list is: " << li.size()<<std::endl; return 0; }
输出:
size of the list is: 3
在此示例中,size()函数返回列表的大小,即3。
链接:https://www.learnfk.comhttps://www.learnfk.com/c++/cpp-list-size-function.html
来源:LearnFk无涯教程网
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)