Same as the previous blog, just put the code like this

1  /* Introduction to the topic: remember a string of numbers you see (the length is not necessarily, it ends with 0, the maximum number is not more than 100, and the number of
 2  
3  numbers is not more than 2^32-1)
 4  memorize and then read it backwards (meaning Do not pronounce the ending number 0).
5  programming to solve this problem. */ 
6  
7  
8  
9 #include <bits/stdc++.h> // Universal header file, don't say anything, search the Internet by yourself 
10  
11  using  namespace std;
 12  
13  int main()
 14  
15  {
 16  
17 stack< int > s; // define a stack 
18  
19  while ( 1 )
 20  
21  {
 22 
23  int a; scanf( " %d " ,&a );
 24  
25  if (!a) break ; // Determine whether to end 
26  
27 s.push(a); // Push a onto the stack 
28  
29  }
 30  
31  while (! s.empty())
 32  
33  {
 34  
35 cout<<s.top(); // print the top element of the stack 
36  
37 printf( "  " ); s.pop(); // the first element on the top of the stack 
38  
39  }
 40  
41 cout <<" \n " ; // newline ignore it =-= return 0; 
42  
43 }

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325250320&siteId=291194637