当前位置:网站首页>Luogu [Beginner Level 4] array p1427 number game of small fish

Luogu [Beginner Level 4] array p1427 number game of small fish

2022-07-06 05:43:00 Python's path to immortality

P1427 Little fish's number game

Title Description
Xiaoyu was recently asked to participate in a number game , Ask it to put the string of numbers it sees ai( The length doesn't have to be , With 0 end ), Remember it and read it backwards ( Number indicating the end 0 Don't read it out ). This is too difficult for the little fish's memory , You don't think about how big the whole head of a small fish is , Some of them are delicious meat ! So please help Xiaoyu program to solve this problem .

Input format
Enter a string of integers in a line , With 0 end , In space .

Output format
Output this string of integers backwards in a line , In space .

I/o sample
Input #1 Copy

3 65 23 5 34 1 30 0

Output #1 Copy

30 1 34 5 23 65 3

explain / Tips
Data scale and agreement

about 00% The data of , Guarantee

0

a

i

2

31

10

0 \leq a_i \leq 2^{31} - 10

0ai23110
No more than 100.

Topics of simple reverse order output
AC Code (C++)

#include <iostream>
#include <array>

using namespace std;

int main()
{ 
    
	array<int, 110>arr;
	int temp = 0;
	int i = 0;
	while (1)
	{ 
    
		cin >> temp;
		// Terminate at zero 
		if (temp == 0)
			break;
		arr[i++] = temp;		
	}
	// Output in reverse order 
	for (i-- ; i >= 0; i--)
		cout << arr[i] << " ";
	return 0;
}

原网站

版权声明
本文为[Python's path to immortality]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202132041412547.html