In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how to reverse the stack string". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Package helloclean;public class StackX {private int maxSize; private char [] stackArray; private int top; public StackX (int max) {maxSize = max; stackArray = new char [maxSize]; top =-1;} public void push (char j) {stackArray [+ + top] = j;} public char pop () {return stackArray [top--] } public char peek () {return stackArray [top];} public boolean isEmpty () {return (top =-1);}} package helloclean;public class Revever {private String input; private String output; public Revever (String in) {this.input = in;} public String rev () {int stackSize = input.length (); StackX stackX = new StackX (stackSize) For (int j = 0; j < input.length (); j + +) {char ch = input.charAt (j); stackX.push (ch);} output = ""; while (! stackX.isEmpty ()) {char ch = stackX.pop (); output = output + ch;} return output;}} package helloclean Import java.util.Scanner;public class ReverseApp {public static void main (String [] args) {String output = "; Scanner scanner = new Scanner (System.in); while (true) {System.out.println (" input: "); String input = scanner.nextLine (); if (input.equals (" Q ")) {System.out.println (" quit! ") ; break;} Revever revever = new Revever (input); output = revever.rev (); System.out.println ("reverse:" + output);}} "how to reverse the stack string" is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.