1112: a plurality of reverse output integer (Special Function)
time limit: 1 Sec memory limit: 128 MB
submitted: 71 Resolution: 59
[Submit] [state] [proposition al: External Import]
Title Description
inputs n integers and n, opposite to the input order sequentially output the n integers. Request does not use array, implemented using a recursive function.
Recursive function process is as follows:
void inverse(int n)
{
if(n >1)
{
(1) 读入一个整数,存入num;
(2) 将后面的n-1个数逆序输出: inverse(n-1);
(3) 输出num;
}
Scanf ( "% D", & NUM);
IF (n-==. 1) directly output NUM;
}
Input
is input two lines, the first line is a positive integer n, there are n integers second row, separated by spaces between integers.
Output
Output n integers, the reverse order of the input sequence, there is a space after every integer.
Sample input the Copy
. 5
. 11 22 is 33 is 44 is 55
sample output from the Copy
55. 11 44 is 33 is 22 is
# include<stdio.h>
void inverse(int n);
int main()
{
int n;
scanf("%d",&n);
inverse(n);
return 0;
}
void inverse(int n)
{
int num;
if(n>1)
{
scanf("%d",&num);
inverse(n-1);
printf("%d ",num);
}
if(n==1)
{
scanf("%d",&num);
printf("%d ",num);
}
}
Note: This question is a feature of a read out one by one.