#include "utils.h" #include bool is_size_ok(int size) { if (size <= 0 || size > 1024) { display_message("size is invalid"); return false; } else { return true; } } vector* fibon_seq(int size) { static vector elems; if (!is_size_ok(size)) { return 0; } int current_size = elems.size(); if (size > current_size) { for (int ix = current_size; ix < size; ++ix) { if (ix < 2) { elems.push_back(1); } else { int value_ix = elems[ix - 1] + elems[ix - 2]; elems.push_back(value_ix); } } } return &elems; } bool fibon_elem(int position, u32& elem) { vector* fibon_vector = fibon_seq(position); if (fibon_vector) { elem = (*fibon_vector)[position - 1]; //index overflow return true; } else { elem = 0; return false; } } int main() { u32 elem = 0; bool ret = fibon_elem(0, elem); if (ret) { cout << "elem is" << elem << endl; } display_message('s'); display_message("test string message", 1); display_message("test string message", 1, 2); string s1("test string message 1"); vector* v1 = fibon_seq(10); display(*v1); display_message(s1, *v1); return 0; }