#include <bits/stdc++.h>
using namespace std;
template <size_t n>
size_t get_array_length(int (&nums)[n])
{
return n;
}
int main() {
int nums[] = {1, 2, 3, 4, 5};
size_t length = get_array_length(nums);
std::cout << "The length of the array is: " << length << std::endl;
// 打印数组中的所有元素
for (size_t i = 0; i < length; ++i) {
std::cout << nums << " ";
}
std::cout << std::endl;
return 0;
} |