**僅給有需要的人以參考,如有不對請糾正我**
= = 這個題目應該就是給一個數值然後依次加上數組索引值之後賦給數組相應位置。
#include<iostream>
template<typename T, typename V>
void iota(T a[], int va, V value)
{
for (int i = 0; i < va; i++)
a[i] = value + i;
}
int main()
{
using namespace std;
int * a;
int size;
int value;
cout << "Input the size of array a: ";
cin >> size;
a = new int[size];
cout << "Enter a number: ";
cin >> value;
iota(a, size, value);
for (int i = 0; i < size; i++)
cout << a[i] << endl;
delete[]a;
return 0;
}