-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
29 lines (23 loc) · 735 Bytes
/
Copy pathmain.cpp
File metadata and controls
29 lines (23 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <my_fibonacci/sequence.hpp>
#include <argparse/argparse.hpp>
#include <iostream>
int main(int argc, char** argv) {
argparse::ArgumentParser program("generate_sequence");
program.add_description(
"Generate a Fibonacci sequence up to the given number of terms.");
program.add_argument("n").help("The number of terms").scan<'i', int>();
try {
program.parse_args(argc, argv);
} catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
}
const auto n = program.get<int>("n");
const auto sequence = my_fibonacci::fibonacci_sequence(n);
for (auto val : sequence) {
std::cout << val << " ";
}
std::cout << std::endl;
return 0;
}