Study Notes 2, struts2 Study Notes

Source: Internet
Author: User

Study Notes 2, struts2 Study Notes

+ =,-=, * =,/= Implies forced type conversion.

In logical operations, the difference between & and & is:

&: No matter whether the left side is true or false, all operations are performed on the right side.

&: If the left side is false, the right side is not involved in the operation. If the left side is true, the right side is involved in the operation.

An exclusive or operation can exchange two integers (no extra space overhead is required ):

A, B;

A = a ^ B;

B = a ^ B;

A = a ^ B;

There are four common methods to implement two integer exchanges:

1) Introduce 3rd variables temp

2) use an exclusive OR operator ^

3) addition and subtraction

A = a + B;

B = a-B;

A = a-B;

4) Get it by one

B = (a + B)-(a = B );

Use a two-dimensional array to save and output the Yang Hui triangle (different rows have different numbers of data ):

/**
*
*/
Package com. yan. javaTest;
Import java. util. collections;

/**
* @ Author Yan
*
*/
Public class YangHuiSanJiao {

/**
* Yang hui san jiao xing.
*
* 1
* 1 1
* 1 2 1
* 1 3 3 1
* 1 4 6 4 1
* 1 5 10 10 5 1
*
* 1. Mei hang de di yi lie he zui hou yi lie dou shi 1;
* 2. Cong di san hang kai shi zhongjianlie de shuzhi wei shangyihang de qianyilie he dangqianlie
* Shuzhi zhihe.
*
*/
Public YangHuiSanJiao (){
// TODO Auto-generated constructor stub
}
/**
* @ Param args
*/
// Array assignment
Int [] [] yangHuiSanJiaoXing (int [] [] str ){
For (int I = 2; I <str. length; I ++) {// from the third line str [2] [];
For (int j = 1; j <str [I]. length-1; j ++) {// from str [I] [1] ---- str [I] [length-2];
Str [I] [j] = str [I-1] [J-1] + str [I-1] [j];
}
}
Return str;
}
// Array format Initialization
Int [] [] arrInit (int [] [] str, int n ){
For (int I = 0; I <n; I ++ ){
Str [I] = new int [I + 1];
Str [I] [0] = 1;
Str [I] [I] = 1;
}
Return str;
}
Public static void main (String [] args ){
// TODO Auto-generated method stub
System. out. println ("Please input a number to assign the lines of the triangle :");
Pipeline SC = new pipeline (System. in );
Int n = SC. nextInt ();
Int [] [] arr = new int [n] [];
YangHuiSanJiao ys = new YangHuiSanJiao ();
Arr = ys. arrInit (arr, n );
Arr = ys. yangHuiSanJiaoXing (arr );
For (int I = 0; I <arr. length; I ++ ){
For (int j = 0; j <arr [I]. length; j ++ ){
System. out. print (arr [I] [j] + "\ t ");
}
System. out. println ();
}
SC. close ();
}

}

Related Article

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.