本文整理汇总了C++中array::at方法的典型用法代码示例。如果您正苦于以下问题:C++ array::at方法的具体用法?C++ array::at怎么用?C++ array::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类array
的用法示例。
在下文中一共展示了array::at方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Given an array of ints, compute recursively if the array contains a 6.
bool array6( array<int, 10> nums, int index )
{
if( nums.size() == index )
return false;
if( nums.at( index ) == 6 )
return true;
return array6( nums, ++index );
}
示例2: createdic
void createdic(vector<knox>& readinvect,array<vector<knox>,100>& dic)
{
auto iter=readinvect.begin();
int viradress;
while(iter!=readinvect.end())
{
viradress=hashing((*iter).studentname);
dic.at(viradress).push_back(*iter);
iter++;
}
}
示例3: main
int main(void)
{
for (int l = 0; l < 1; l++) {
init();
for (double t = 1; t < time_end; t++) {
process(t);
}
//int check = 1;
// for (int i = 0; i < node_number; i++) {
// if (k.at(i).x + k.at(i).y + k.at(i).z == 0) check = 0;
// }
//if (check == 1) cout << "OK" << endl;
//else cout << "Not OK" << endl;
cout << k.at(0).x << " " << k.at(0).y << " " << k.at(0).z << " " << k.at(0).inside_nut << endl;
// if (l % 2 == 0) {
// cout << type_number.first << " " << type_number.second << endl;
// take_log << type_number.first << " " << type_number.second << endl;
// }
}
return 0;
}
示例4: main
/*
@copyright Louis Dionne 2014
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
#include <boost/hana/detail/sandbox/array.hpp>
using namespace boost::hana;
using sandbox::array;
constexpr array<int, 4> a = {{0, 1, 2, 3}};
constexpr array<int, 6> b = {{5, 4, 3, 2, 1, 0}};
static_assert(a[0] == 0, "");
static_assert(a[1] == 1, "");
static_assert(a[2] == 2, "");
static_assert(a[3] == 3, "");
static_assert(a.at(0) == 0, "");
static_assert(a.at(1) == 1, "");
static_assert(a.at(2) == 2, "");
static_assert(a != b, "");
static_assert(a < b, "");
int main() { }
示例5: process
void process(double t)
{
//nodeの内部変化
nutorition = decide_nut(t);
//give_nut(nutorition);
for (int j = 0; j < node_number; j++) {
k.at(j) = internal(k.at(j), nutorition);
}
//分裂
for (int j = 0; j < node_number; j++) {
if (k.at(j).z > k.at(j).init_z * 2) {
node_number++;
pair<Node, Node> dev;
dev = devide(k.at(j));
k.at(j) = dev.first;
if (node_number == node_max) { //node_maxを越えると外に流れ出る
node_number--;
int get;
do {
get = rdom() % node_number;
} while (get == j);
k.at(get) = dev.second;
} else {
k.at(node_number - 1) = dev.second;
}
} else if (k.at(j).z < k.at(j).init_z * 0.5) { //zが1/2になると消滅
k.at(j) = k.at(node_number - 1);
node_number--;
}
}
type_number.first = 0;
type_number.second = 0;
for (int j = 0; j < node_number; j++) {
if (k.at(j).type == 0) {
type_number.first++;
} else {
type_number.second++;
}
}
cout << t << " " << type_number.first << " " << type_number.second << endl;
take_log << t << " " << type_number.first << " " << type_number.second << endl;
total_size = get_total_size();
}
示例6: init
void init(void)
{
//nutorition
aver_nut = 0.1;
nut_coef = 1;
//one
k.at(0).type = 0;
k.at(0).inside_nut = 0.1;
k.at(0).a = 0.1;
k.at(0).b = 0.1;
k.at(0).c = 0.1;
k.at(0).x = 0.1;
k.at(0).y = 0.1;
k.at(0).z = 0.1;
k.at(0).prev_nut = 0;
k.at(0).prev_x = 0;
k.at(0).prev_y = 0;
k.at(0).prev_z = 0;
k.at(0).size = get_size(k.at(0));
k.at(0).init = k.at(0).size;
k.at(0).init_z = k.at(0).z;
//two
k.at(1).type = 1;
k.at(1).inside_nut = 0.1;
k.at(1).a = 0.5;
k.at(1).b = 0.5;
k.at(1).c = 0.5;
k.at(1).x = 0.1;
k.at(1).y = 0.1;
k.at(1).z = 0.1;
k.at(1).prev_nut = 0;
k.at(1).prev_x = 0;
k.at(1).prev_y = 0;
k.at(1).prev_z = 0;
k.at(1).size = get_size(k.at(1));
k.at(1).init = k.at(1).size;
k.at(1).init_z = k.at(1).z;
total_size = get_total_size();
node_number = init_node_number;
for (int i = 2; i < 50; i++) {
if (i % 2 == 0) {
k.at(i) = k.at(0);
} else {
k.at(i) = k.at(1);
}
}
coef_decrease = 0.01;
}