⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stringinput.java

📁 caculater in the ssd any...asdf sadf
💻 JAVA
字号:
package bluewater;

import java.io.*;

public class StringInput {

	private static BufferedReader stdIn = new BufferedReader(
			new InputStreamReader(System.in));

	// private static PrintWriter stdOut = new PrintWriter(System.out);

	private static PrintWriter stdErr = new PrintWriter(System.err);

	public static boolean beRight(String x) {
		// the number of ( is not equal the number of )
		int left = 0, right = 0;
		for (int i = 0; i < x.length(); i++) {
			if (x.charAt(i) == '(')
				left++;
			if (x.charAt(i) == ')')
				right++;
		}
		if (left != right){
			stdErr.println("the number of ( is not equal the number of )");
			return false;
		}
		//more another wrong answer
		//to be continue ...
		return true;
	}

	public String input() {
		String b = "";
		boolean f = true;
		while (f) {
			f = false;
			try {
				b = stdIn.readLine();
				if (!beRight(b))
					throw new IOException();
			} catch (IOException e) {
				stdErr.println("input err please input again:");
				f = true;
			}
		}
		return b;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -