Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the real titles of the java Blue Bridge Cup over the years?

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

What are the real problems of java Blue Bridge Cup over the years? I believe many inexperienced people don't know what to do about it. Therefore, this paper summarizes the causes and solutions of the problems. Through this article, I hope you can solve this problem.

Blue Bridge Cup java real questions and answers over the years (closed for a month, painstaking efforts to sort out)

1 full permutation

The thing is, if you give N different characters and arrange them all, the final result will be N! Kind of. For example, given three different characters A, B and C, the result is: ABC, ACB, BAC, BCA, CAB, CBA.

Package Question1_9;import java.util.Scanner;import java.util.Vector;public class Question1 {public static long count=0; private void fullPermutation (Vectorsourse, Vector result) {if (sourse.size () = = 0) {for (int I = 0; I)

< result.size(); i++) { System.out.print(result.elementAt(i)); } System.out.print("\n"); count++; return; } for (int i = 0; i < sourse.size(); i++) { Vectortsourse=new Vector(sourse); Vectortresult=new Vector(result); tresult.add(sourse.elementAt(i)); tsourse.remove(i); new Question1().fullPermutation(tsourse, tresult); } } public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int n=scanner.nextInt(); Vector sourse=new Vector(); Vector result=new Vector(); for (int i = 0; i < n; i++) { sourse.add((char)('A'+i)); } new Question1().fullPermutation(sourse, result); System.out.println(Question1.count); }} 2串的简单处理 串的处理 在实际的开发工作中,对字符串的处理是最常见的编程任务。本题目即是要求程序对用户输入的串进行处理。具体规则如下: 把每个单词的首字母变为大写。 把数字与字母之间用下划线字符(_)分开,使得更清晰 把单词中间有多个空格的调整为1个空格。 例如:用户输入:you and me what cpp2005program则程序输出:You And Me What Cpp_2005_program用户输入:this is a 99cat则程序输出:This Is A 99_cat 我们假设:用户输入的串中只有小写字母,空格和数字,不含其它的字母或符号。每个单词间由1个或多个空格分隔。假设用户输入的串长度不超过200个字符。 package Question1_9;import java.util.Scanner;import java.util.Vector;public class Question2 { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); String string=scanner.nextLine(); Vectorvector=new Vector(); for (int i = 0; i < string.length(); i++) { vector.add(string.charAt(i)); } try { int index=0; while (index='a'&&vector.elementAt(index)='a'&&vector.elementAt(index)='a'&&vector.elementAt(index)='0'&&vector.elementAt(index-1)='a'&&vector.elementAt(index-1)='0'&&vector.elementAt(index) &空格 --->

< --->

-> > "--> in addition, according to the characteristics of the source code, TAB can be converted to 4 spaces to display. TAB-- > in order to appear as a newline, you need to tag the end of the line. In order to show the beauty, bold the keywords, that is, tag the keywords around. For example, public displays single-line comment text in green, and you can use tags such as: / / this is my single-line comment! Note: if "/ /" appears in a string, be careful not to mistakenly turn green. Ignore the problem of multiline comments / *. * / / or * / / *. * / / * your task is to write a program that converts a given source file into a corresponding html representation. [input and output format requirements] the source file a.txt, which contains standard java source files, is stored in the same directory as your program. It is required to write a program to convert it to b.html. For example, the current a.txt file corresponds to the b.html file. You can use notepad to open b.html to view the converted content. Open b.html with a browser and you can see the effect of the display. Note: the a.txt used in the actual evaluation is different from the example. * / package Question10_19;import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStreamReader;import java.io.OutputStreamWriter;public class Question15FinishedBefore {private String BoldComments (String tempString, String note) {return null;} public static void main (String [] args) {try {File inFile = new File ("test.java"); FileInputStream fileInputStream; fileInputStream = new FileInputStream (inFile) InputStreamReader inputStreamReader = new InputStreamReader (fileInputStream); BufferedReader bufferedReader = new BufferedReader (inputStreamReader); File outFile = new File ("test.html"); FileOutputStream fileOutputStream = new FileOutputStream (outFile); OutputStreamWriter outStreamWriter = new OutputStreamWriter (fileOutputStream); BufferedWriter bufferedWriter = new BufferedWriter (outStreamWriter); outStreamWriter.write ("\ n"); outStreamWriter.write ("\ n"); String tempString; while ((tempString = bufferedReader.readLine ())! = null) {tempString = tempString.replaceAll ("&", "&"); tempString = tempString.replaceAll ("", ") TempString = tempString.replaceAll (""); int index1 = tempString.lastIndexOf ("/ /"); int index2 = tempString.indexOf ("\"); if (index1! =-1 & & index2 = =-1) {String S1 = tempString.substring (0, index1); String S2 = tempString.substring (index1); S2 = "+ S2 +"; tempString = S1 + S2;} else if (index1! =-1 & index2! =-1) {int startMark =-1, endMark =-1; boolean isNote = true For (int I = 0; I

< tempString.length(); i++) { if ('\"' == tempString.charAt(i)) { if (startMark == -1) { startMark = i; } else { endMark = i; if (index1 >

StartMark & & index1

< endMark) { isNote = false; break; } else { startMark = -1; endMark = -1; } } } } if (isNote == true) { String s1 = tempString.substring(0, index1); String s2 = tempString.substring(index1); s2 = "" + s2 + ""; tempString = s1 + s2; } } tempString = tempString.replaceAll("\"", """); tempString = tempString.replaceAll("\t", ""); tempString = tempString.replaceAll("public", "public"); tempString = tempString.replaceAll("class", "class"); tempString = tempString.replaceAll("static", "static"); tempString = tempString.replaceAll("void", "void"); outStreamWriter.write(tempString + "" + "\r\n"); } outStreamWriter.write("\n\n"); outStreamWriter.write("\n"); bufferedWriter.flush(); bufferedReader.close(); bufferedWriter.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }} 运行结果: // 我的工具类public class MyTool{ public static void main(String[] args) { int a = 100; int b = 20; if(a>

B & & true) System.out.println (a); else System.out.println ("this! / / aaa//kkk"); / / Test whether the comments are correct}}

16. Quantitative period

/ * the driving force behind complex phenomena may be extremely simple principles. One of the goals of science is to discover the simple laws behind numerous and complex natural phenomena. Einstein's theory of relativity is an exemplary example of this. In the early days, biologists were puzzled when they observed how the number of certain insects (called insect population) in a certain area changed year by year: sometimes it gradually increased to a balanced value. Sometimes it jumps periodically between two numbers. Sometimes it goes into chaos, changing like a random number (called chaos). Slowly, people observed this phenomenon more clearly from mathematics, and thus opened up: symbolic dynamics, nonlinear dynamics and other research fields. A well-known simplified model of the number of insects is as follows: X'= x * (1-x) * r here, x x'r is a floating point number. Among them, x represents the number of insects in the current year, and x 'represents the number of insects in the next year. Their values range from 0 to 1, which actually represents the ratio of the total number of worms to the maximum number that the environment can support. R is a constant (environmental parameter), and the value range of r is in [0pr 4]. What's surprising is that this simple iterative formula has an unusually mysterious nature! Generally speaking, after many iterations, the stable mode of the number of worms has nothing to do with the initial value of x, but has something to do with r! For example, no matter what the initial value of x is, when r = 2.5, x tends to 0.6 after multiple iterations. When r = 3. 2, the value of x tends to oscillate periodically between 0.799 and 0.513. So, when r = 3.62, did you observe any periodic phenomena? There is no need to submit the source code, just write your conclusion! The answer is written in "answer .txt", not here. * / public class Demo01 {static int count= 100; / / perform 100th exits of public static void f (double xmagedere double r) {if (countdown 1cards! array [I-1]);} Scanner scanner=new Scanner (System.in); int n=scanner.nextInt (); int total; scanner.nextLine (); while ((NMAV -) > 0) {total=scanner.nextInt (); System.out.println (array [total]? 1:0);}

Run result: 4121018 output result: 0110

19. Cipher generator

/ * when setting passwords for important permissions such as bank accounts, we often encounter such troubles: if we set a password that is difficult to remember, it is easy to crack and not safe; if we set a password that is difficult to remember, we are afraid that we will forget it, and if we write it on paper, we are afraid that the paper will be found or lost. The task of this program is to convert a string of phonetic letters into 6 digits (passwords). We can use any easy-to-remember pinyin string (such as the name, Wang Ximing, just write: wangximing) as input, and the program outputs 6 digits. The process of transformation is as follows: the first step. Fold the string in groups of 6, for example, wangximing becomes: wangximing step 2. Add the ascii code values of all characters perpendicular to the same position to get six digits, such as the above example: step 3: 228 202 220 206 120 105. Then "indent" each number: it is to add the numbers of each digit, and if the number is not a digit, it will be indented again until it becomes a digit. For example, the number above is indented to: 344836, which is the final output of the program! The program is required to receive data from standard input and output results on standard output. The input format is: the first line is an integer n (= 10) {sroomn + "; for (int I = 0; I)

< s.length(); i++) { n+=s.charAt(i)-'0'; } } return n; } public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int n=scanner.nextInt(); String s; scanner.nextLine(); while((n--)>

0) {int array [] = new int [6]; s=scanner.nextLine (); for (int I = 0; I < s.length (); iArray +) {for [I% 6] + = (int) (s.charAt (I));} for (simplify (array [I])) {System.out.print (simplify (array [I]));} System.out.println ();} / / System.out.println (simplify (123456789));}}

Run result: enter the integer n (= n.length) return; for (int kappa 0 * * k)

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report