#include <iostream> #include <cstdint> #include <vector> #include <random> typedef std::vector<std::int64_t> DType; DType MakeVector(const std::size_t& N, const unsigned int& S = 0) { std::int64_t Range = 16; std::mt19937 mt(S); std::uniform_int_distribution<std::int64_t> ui(-Range, Range); DType D; for (std::size_t i = 0; i < N; i++) { D.push_back(ui(mt)); } return D; } DType MakeHoge(const DType& D) { DType R; for (std::size_t i = 0; i < D.size() - 1; i++) { R.push_back(D[i] - D[i + 1]); } return R; } bool Show(const DType& D, const DType& R) { for (auto& o : D) { std::cout << o << ','; } std::cout << std::endl; std::cout << std::endl; for (auto& o : R) { std::cout << o*-1 << ','; } std::cout << std::endl; return true; } int main() { DType D; DType R; std::size_t L = 16; D = MakeVector(L); R = MakeHoge(D); Show(D, R); return 0; }
Standard input is empty