题目描述

(Optional) In C++, an array can be defined in this way: int a[10]; where a is an array with 10 integer values. The value of this array can be assigned as follows: a[0] = 10; where the first element of a is assigned to 10.
Write a program that uses the following functions:
Fill_array() takes as arguments the name of an array of double values and an array size. It prompts the user to enter double values to be entered in the array. It ceases taking input when the array is full or when the user enters non-numeric input, and it returns the actual number of entries.
Show_array() takes as arguments the name of an array of double values and an array size and displays the contents of the array.
Reverse_array() takes as arguments the name of an array of double values and an array size and reverses the order of the values stored in the array.
The program should use these functions to fill an array, show the array, reverse the array, show the array.


输入格式

The input consists of 10 double values(range from 0 to 10000)


输出格式

The first line shows the input array.
The second line shows the reversed array.
The decimal precision of output is 2.


样例数据

输入

1 2 3 4 5 6 7 8 9 10

输出

1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00
10.00 9.00 8.00 7.00 6.00 5.00 4.00 3.00 2.00 1.00

备注

The main function is provided, you only need to complete the function Fill_array, Show_array, and Reverse_array.

#include<iostream>
#include <iomanip> // parameterized stream manipulators
using namespace std;

void Fill_array(double [], int);
void Show_array(double [], int);
void Reverse_array(double [], int);

int main(){
    cout << fixed << setprecision( 2 );
    double a[10];
    Fill_array(a, 10);
    Show_array(a, 10);
    Reverse_array(a, 10);
    Show_array(a, 10);
    return 0;
}

操作

评测记录

优秀代码

信息

时间限制: 1s
内存限制: 128MB
评测模式: Normal

题解