Third Blog Job

Source: Internet
Author: User

1.

1) There is no limit to the length of the entered number, no input number type is defined.

2) code fixed dead input format, and if the judging condition is incomplete

3) public string Getphonenumber (string strphonenum) {
if ((strphonenum==null) | | | "". Equals (Strphonenum)) {

if (Strphonenum.length () ==15) {

for (int a=0;a<15;a++) {

true = Strphonenum.substring (5, 12);

}

Return ' true ';}

}else{

Return ' false ';

SYSTEM.OUT.PRINTLN ("Input Error! ");

}

String[] Arrphone=strphonenum.split ("-");
return arrphone[1];

}

2. (1)

Package WJZ;

public class ArraySort {
Public int[] Sort (int[] a) {//Create ArraySort method
for (int i=0;i<a.length;i++) {
for (int j=i+1;j<a.length; j + +) {//loop to compare adjacent two numbers within an array of arrays
if (A[i]>a[j]) {
int temp=a[i];
A[I]=A[J];
a[j]=temp;//Select sort from large to small
}
}
}
Return a;//returns the sorted array
}
public static void Main (string[] args) {
TODO auto-generated Method Stub
Int[] i={1,4,5,6,9,11,5,-8,-44,5};
SYSTEM.OUT.PRINTLN ("The result after sorting is:");
ArraySort x = new ArraySort ();
Int[] B=x.sort (i);
for (int a = 0;a<b.length;a++) {
System.out.println (B[a]);
}
}
}

(2) Comparing I and J, if I is larger than J, then it is invariant, conversely, I will be transferred to the front of J, and then the order from large to small can be obtained.

(3) I. Array is empty

Two. Some elements in the array are the same

Three. The order of the values of the array has been sorted out

Four. All values in the array are equal

Five. The order in the array is reversed

Third Blog Job

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.