#include <iostream> #include <vector> #include <tuple> using namespace std; int main() { vector<tuple<int,int,double>> box; for (int i{1}; i < 10; ++i) box.push_back(make_tuple(i, i*i, (double)i/(i*i))); for (auto [idx, square, value]: box) cout << idx << " " << square << " " << value << endl; while (!box.empty()) { auto [idx, square, value] = box.back(); box.pop_back(); cout << idx << " " << square << " " << value << endl; } return 0; }
沒有留言:
張貼留言