2015 Huawei Recruitment machine Questions and Answers __java learning

Source: Internet
Author: User
Tags static class
import Java.util.Scanner; /** * Determines whether a string is a first-letter uppercase and is not the first letter lowercase. Input: An arbitrary string that is no longer than 128 characters * Output: Returns True if the first character of the input string is uppercase and other characters Fu Fei uppercase letters * Other cases (empty string, Fu Fei letter, first letter lowercase, first letter uppercase but other words Fu Fei letters) return FALSE * Sample input: Hello World * Sample output: TRUE * @author Yutao * * */public class Strjudge {public static void main (string[] args)
		{Scanner input = new Scanner (system.in);
		String src = input.nextline ();
		Input.close ();
	System.out.println (judge (SRC));
		public static Boolean judge (String src) {if (Src.charat (0) < ' A ' | | | src.charat (0) > ' Z ') {return false;
						else {for (int i = 1; i < Src.length ()-1; i++) {if (Src.charat (i) < ' a ' | | src.charat (i) > ' z ')
				&& Src.charat (i)!= ' ') {return false;
		} return true; }
	}
}
<pre class= "java" abp= "655" name= "code" >/** * Display names based on caller ID * When the phone calls will automatically match the phone number to save the name in the telephone book, When the phone number matching will generally be based on the number of digits after the match, * because different network environment issued by the number may be different, for example, some regions display area code, some may not show area code. The subject requirements are as follows: * On the caller number after the N-bit match, n through the parameter read to obtain, output all the matching number of names, many personal name between the 1:int * parameter type, the possible value of 0,7,8,9, when 0 need to exact match the caller number, That is to say, the number in the phone book and the caller number must be the same. * Parameter 2: string, for the caller number * Match the name, the number match fails to display "unknown" (excluding quotes) * Sample input: 7 09282357 * Sample output: Jane Cora * Tip: * Phone number length will not be less than the length to match * telephone number if less than the length to match, to skip, do not compare * matches are matched from the back of the string, such as number 12345678, when the 7-bit match, only the next 7 digits, that is 2345678 * phone number is used as follows Data, written directly into the code: * Person persons[] = {New Person ("Jack", "13572105859"), New Person ("Tom", "008602989282356"), New Pe Rson ("Ada", "02989282356"), New Person ("Alice", "89282356"), New Person ("Carmen", "01089282356"), New person ("Franc Es "," 123 "), New Person (" Jane "," 89282357 "), New person (" Selina "," 18220191828 "), New Person (" Ellen "," 18220191828 ")
, the new person ("Kitty", "456781234"), the new person ("Cora", "09282357"), the new person ("0", "0")}; * * public classphonematch {static person persons[] = {New Person ("Jack", "13572105859"), New Person ("Tom", "008602989282356" 
				), the new person ("Ada", "02989282356"), the new person ("Alice", "89282356"), the new person ("Carmen", "01089282356"), New Person ("Frances", "123"), New Person ("Jane", "89282357"), New person ("Selina", "18220191828"), New Perso N ("Ellen", "18220191828"), New Person ("Kitty", "456781234"), New Person ("Cora", "09282357"), New Person ("0",

	"0")};
	public static void Main (string[] args) {System.out.println (getName (0, "008602989282356"));
		public static string GetName (int count, String phone) {String result = ' ";
				if (count = = 0) {//Exact match for (person P:persons) {if (p.phone.equals) {if (phone)} {result = P.name + ""; }} else {//count=7,8,9 string temp1 = "";//caller number intercept count bit string temp2 = "";//local number intercept count bit string int le N1 = Phone.length ()//number digits int len2 = 0;//number digits in the currently compared number for p:persons) {len2 = P.phone.length ();
						if (len1 = = len2) {if (Len1 < count) {if (P.phone.equals (phone)) {result = P.name + "";
						}}else {temp1 = phone.substring (Len1-count);
						Temp2 = p.phone.substring (Len2-count);
						if (Temp2.equals (TEMP1)) {result = P.name + ""; }} else {if (len1 >= count && len2 >= count) {Temp1 = phone.substring (len1-count
						);
						Temp2 = p.phone.substring (Len2-count);
						if (Temp2.equals (TEMP1)) {result = P.name + ""; }}} return Result.equals ("")?
	Unknown ": result.substring (0,result.length ()-1);
		public static class Person {private String name;

		Private String phone;
			Public person (string name, String phone) {this.name = name;
		This.phone = phone; }
	}
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.