- void f(T a[],int n)
- {
- T t;
- for (int i = 0; i < n / 2; i++)
- {
- t = a[i];
- a[i] = a[n-i-1];
- a[n - i - 1] = t;
- }
- };
- int main()
- {
- int a[5] = {
- 1,21,134,40,50
- };
- int i;
- double d[6] = {
- 2.3,10.1,19.1,8.4,7.2
- };
- f(a,5);
- f(d,6);
- for (i = 0; i < 5; i++)
- cout << a[i] << " ";
- cout << endl;
- for (i = 0; i < 6; i++)
- cout << d[i] << " ";
- cout << endl;
- system("pause");
- return 1;
- }
来源: http://www.bubuko.com/infodetail-3408707.html