Topic one input two strings, output matching number of times, such as AAAAC and AA output 2
I didn't think of this water, the regular expression can also be import java.util.scanner;import Java.util.regex.matcher;import Java.util.regex.pattern;public class main{public static void Main (string[] args) {Scanner sc=new Scanner (system.in); String S1; String s2;int Count=0;while (Sc.hasnext ()) {count=0;s1=sc.next (); S2=sc.next (); Matcher matcher=pattern.compile (S2). Matcher (S1); while (Matcher.find ()) {count++;} System.out.println (count);}}}
Topic two has a list of comma-separated numbers, sorted output, output requirements, sequential output only the beginning and end of the number, all other cases output
Import Java.util.arraylist;import java.util.collections;import Java.util.list;import Java.util.Scanner;public class Copyofcopyofmain {public static void main (string[] args) {Scanner sc = new Scanner (system.in); String S1;while (Sc.hasnext ()) {S1 = Sc.next (); string[] Nums = S1.split (","); list<integer> list = new arraylist<> (); for (string string:nums) {List.add (Integer.parseint (String));} if (list.size () = = 1) {System.out.println (list.get (0)); continue;} Collections.sort (list); System.out.print (list.get (0)); for (int i = 1; i < List.size ()-1; i++) {if (List.get (i)-list.get (i-1) = = 1 &am p;& List.get (i + 1)-list.get (i) = = 1) {} else {System.out.print (""); System.out.print (List.get (i));}} System.out.println ("" + List.get (List.size ()-1);}}}
Topic Three
This problem is the most water, Java a sentence to fix, C + + words can only realize the import Java.math.BigInteger; Import Java.util.scanner;public class Copyofcopyofmain {public static void main (string[] args) {Scanner sc = new Scanner (S ystem.in); String S1;while (Sc.hasnext ()) {S1 = Sc.nextline (); String nums[]=s1.split ("+"); System.out.println (New BigInteger (Nums[1]). Subtract (new BigInteger (Nums[0]));}}}
Half an hour all done, once through
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Huawei School recruit Hangxia Programming topic