bài 1:
<div class="bbcodeblock bbcodequote bbcmspoilerblock">
<div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>
show spoiler
hide spoiler
</div>
<div class="quotecontent">
<div class="bbcm_spoiler_noscript"><blockquote>
Mã nguồn PHP:
[color=#000000]
package basic[/color][color=#007700]; [/color][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]scanner[/color][color=#007700];[/color][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]inputmismatchexception[/color][color=#007700]; public class [/color][color=#0000bb]arrayofstudents [/color][color=#007700]{ private [/color][color=#0000bb]int numberofstudents[/color][color=#007700];private [/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]name[/color][color=#007700];private static [/color][color=#0000bb]scanner input [/color][color=#007700]= new [/color][color=#0000bb]scanner[/color][color=#007700]( [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]in [/color][color=#007700]); public [/color][color=#0000bb]arrayofstudents[/color][color=#007700](){[/color][color=#0000bb]boolean continueloop [/color][color=#007700]= [/color][color=#0000bb]true[/color][color=#007700];[/color][color=#0000bb]int temp [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700];[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print( [/color][color=#dd0000]"enter number of students: " [/color][color=#007700]); while ( [/color][color=#0000bb]continueloop [/color][color=#007700]){try{[/color][color=#0000bb]temp [/color][color=#007700]= [/color][color=#0000bb]integer[/color][color=#007700].[/color][color=#0000bb]parseint[/color][color=#007700]( [/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]() );if ( [/color][color=#0000bb]temp [/color][color=#007700]< [/color][color=#0000bb]0 [/color][color=#007700])throw new [/color][color=#0000bb]illegalargumentexception[/color][color=#007700]();else[/color][color=#0000bb]continueloop [/color][color=#007700]= [/color][color=#0000bb]false[/color][color=#007700];}catch( [/color][color=#0000bb]inputmismatchexception [/color][color=#007700]| [/color][color=#0000bb]illegalargumentexception e [/color][color=#007700]){[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print( [/color][color=#dd0000]"please enter again!" [/color][color=#007700]);}} [/color][color=#0000bb]numberofstudents [/color][color=#007700]= [/color][color=#0000bb]temp[/color][color=#007700];[/color][color=#0000bb]name [/color][color=#007700]= new [/color][color=#0000bb]string[/color][color=#007700][ [/color][color=#0000bb]numberofstudents [/color][color=#007700]]; [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"enter name of each student"[/color][color=#007700]);for ( [/color][color=#0000bb]int i [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]i [/color][color=#007700]< [/color][color=#0000bb]numberofstudents[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++ ){[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]printf[/color][color=#007700]( [/color][color=#dd0000]"%s %d\t"[/color][color=#007700], [/color][color=#dd0000]"student "[/color][color=#007700], [/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1 [/color][color=#007700]);[/color][color=#0000bb]name[/color][color=#007700][ [/color][color=#0000bb]i [/color][color=#007700]] = [/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]();}} public [/color][color=#0000bb]void run[/color][color=#007700](){[/color][color=#0000bb]string str [/color][color=#007700]= [/color][color=#dd0000]""[/color][color=#007700];[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]( [/color][color=#dd0000]"find a student with his name"[/color][color=#007700]);while( [/color][color=#0000bb]true [/color][color=#007700]){while( [/color][color=#0000bb]str [/color][color=#007700]== [/color][color=#dd0000]"" [/color][color=#007700]){[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print( [/color][color=#dd0000]"please enter a name: " [/color][color=#007700]);[/color][color=#0000bb]str [/color][color=#007700]= [/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]();} [/color][color=#0000bb]int position [/color][color=#007700]= [/color][color=#0000bb]search[/color][color=#007700]( [/color][color=#0000bb]str [/color][color=#007700]);if ( [/color][color=#0000bb]position [/color][color=#007700]>= [/color][color=#0000bb]0 [/color][color=#007700])[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]( [/color][color=#dd0000]"found at position " [/color][color=#007700]+ ( [/color][color=#0000bb]position [/color][color=#007700]+ [/color][color=#0000bb]1 [/color][color=#007700]) );else[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]( [/color][color=#dd0000]"not found!" [/color][color=#007700]); [/color][color=#ff8000]//ask user to continue or not?[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print( [/color][color=#dd0000]"do yout want to find an other student? enter y for new search" [/color][color=#007700]+[/color][color=#dd0000]" or an other button for ending"[/color][color=#007700]);[/color][color=#0000bb]string temp [/color][color=#007700]= [/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]();if ( [/color][color=#0000bb]temp[/color][color=#007700].[/color][color=#0000bb]charat[/color][color=#007700]( [/color][color=#0000bb]0 [/color][color=#007700]) != [/color][color=#dd0000]'y' [/color][color=#007700])[/color][color=#0000bb]system[/color][color=#007700].exit( [/color][color=#0000bb]0 [/color][color=#007700]);else[/color][color=#0000bb]str [/color][color=#007700]= [/color][color=#dd0000]""[/color][color=#007700];}} private [/color][color=#0000bb]int search[/color][color=#007700]( [/color][color=#0000bb]string str [/color][color=#007700]){[/color][color=#0000bb]int counter [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700];while ( [/color][color=#0000bb]counter [/color][color=#007700]< [/color][color=#0000bb]numberofstudents [/color][color=#007700]){if ( [/color][color=#0000bb]str[/color][color=#007700].[/color][color=#0000bb]equalsignorecase[/color][color=#007700]( [/color][color=#0000bb]name[/color][color=#007700][ [/color][color=#0000bb]counter [/color][color=#007700]] ) )return [/color][color=#0000bb]counter[/color][color=#007700];else[/color][color=#0000bb]counter[/color][color=#007700]++;}return -[/color][color=#0000bb]1[/color][color=#007700];} public static [/color][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]args[/color][color=#007700]) {[/color][color=#0000bb]arrayofstudents newtest [/color][color=#007700]= new [/color][color=#0000bb]arrayofstudents[/color][color=#007700]();[/color][color=#0000bb]newtest[/color][color=#007700].[/color][color=#0000bb]run[/color][color=#007700]();} }[/color]
</blockquote></div>
</div>
</div>
bài 2: chưa nhớ lắm các cách sắp xếp khác nên tạm thời để đấy. có gì mình sửa lại sau
<div class="bbcodeblock bbcodequote bbcmspoilerblock">
<div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>
show spoiler
hide spoiler
</div>
<div class="quotecontent">
<div class="bbcm_spoiler_noscript"><blockquote>
Mã nguồn PHP:
[color=#000000]
package basic[/color][color=#007700]; [/color][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]arrays[/color][color=#007700]; public class [/color][color=#0000bb]sortingarray [/color][color=#007700]{ private static final [/color][color=#0000bb]int[/color][color=#007700][] [/color][color=#0000bb]unsorted [/color][color=#007700]= { [/color][color=#0000bb]6[/color][color=#007700], [/color][color=#0000bb]4[/color][color=#007700], [/color][color=#0000bb]2[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]6[/color][color=#007700], [/color][color=#0000bb]3[/color][color=#007700], [/color][color=#0000bb]12[/color][color=#007700], [/color][color=#0000bb]10[/color][color=#007700], [/color][color=#0000bb]7[/color][color=#007700], [/color][color=#0000bb]9[/color][color=#007700], [/color][color=#0000bb]5[/color][color=#007700], [/color][color=#0000bb]3 [/color][color=#007700]};private [/color][color=#0000bb]int[/color][color=#007700][] [/color][color=#0000bb]sorted[/color][color=#007700];private [/color][color=#0000bb]int length[/color][color=#007700]; [/color][color=#ff8000]// constructor[/color][color=#007700]public [/color][color=#0000bb]sortingarray[/color][color=#007700](){[/color][color=#0000bb]length [/color][color=#007700]= [/color][color=#0000bb]unsorted[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700];[/color][color=#0000bb]sorted [/color][color=#007700]= new [/color][color=#0000bb]int[/color][color=#007700][ [/color][color=#0000bb]length [/color][color=#007700]];} [/color][color=#ff8000]// print array after sorting ( mac du ket qua giong nhau =)) )[/color][color=#007700]public [/color][color=#0000bb]void display[/color][color=#007700]( [/color][color=#0000bb]string str [/color][color=#007700]){[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]( [/color][color=#dd0000]"
array after " [/color][color=#007700]+ [/color][color=#0000bb]str [/color][color=#007700]+ [/color][color=#dd0000]" : " [/color][color=#007700]);for( [/color][color=#0000bb]int i [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]i [/color][color=#007700]< [/color][color=#0000bb]length[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++ ){[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]printf[/color][color=#007700]( [/color][color=#dd0000]"%d "[/color][color=#007700], [/color][color=#0000bb]sorted[/color][color=#007700][ [/color][color=#0000bb]i [/color][color=#007700]] );}} [/color][color=#ff8000]// bubble sorting[/color][color=#007700]public [/color][color=#0000bb]int[/color][color=#007700][] [/color][color=#0000bb]bubblesort[/color][color=#007700](){[/color][color=#0000bb]int[/color][color=#007700][] [/color][color=#0000bb]temp [/color][color=#007700]= [/color][color=#0000bb]arrays[/color][color=#007700].[/color][color=#0000bb]copyof[/color][color=#007700]( [/color][color=#0000bb]unsorted [/color][color=#007700], [/color][color=#0000bb]length [/color][color=#007700]);for( [/color][color=#0000bb]int i [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]i [/color][color=#007700]< [/color][color=#0000bb]length [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++ )for ( [/color][color=#0000bb]int j [/color][color=#007700]= [/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700]; [/color][color=#0000bb]j [/color][color=#007700]< [/color][color=#0000bb]length[/color][color=#007700]; [/color][color=#0000bb]j[/color][color=#007700]++ ){if ( [/color][color=#0000bb]temp[/color][color=#007700][ [/color][color=#0000bb]i [/color][color=#007700]] > [/color][color=#0000bb]temp[/color][color=#007700][ [/color][color=#0000bb]j [/color][color=#007700]] ){[/color][color=#0000bb]int value [/color][color=#007700]= [/color][color=#0000bb]temp[/color][color=#007700][ [/color][color=#0000bb]i [/color][color=#007700]];[/color][color=#0000bb]temp[/color][color=#007700][ [/color][color=#0000bb]i [/color][color=#007700]] = [/color][color=#0000bb]temp[/color][color=#007700][ [/color][color=#0000bb]j [/color][color=#007700]];[/color][color=#0000bb]temp[/color][color=#007700][ [/color][color=#0000bb]j[/color][color=#007700]] = [/color][color=#0000bb]value[/color][color=#007700];}} return [/color][color=#0000bb]temp[/color][color=#007700];} [/color][color=#ff8000]// insertion sort//public int[] insertionsort()//{ //} [/color][color=#007700]public [/color][color=#0000bb]void run[/color][color=#007700](){[/color][color=#0000bb]sorted [/color][color=#007700]= [/color][color=#0000bb]bubblesort[/color][color=#007700]();[/color][color=#0000bb]display[/color][color=#007700]( [/color][color=#dd0000]"bubble sort" [/color][color=#007700]);} public static [/color][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]args[/color][color=#007700]){[/color][color=#0000bb]sortingarray newtest [/color][color=#007700]= new [/color][color=#0000bb]sortingarray[/color][color=#007700]();[/color][color=#0000bb]newtest[/color][color=#007700].[/color][color=#0000bb]run[/color][color=#007700]();} }[/color]
</blockquote></div>
</div>
</div>
bài 3 :d
<div class="bbcodeblock bbcodequote bbcmspoilerblock">
<div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>
show spoiler
hide spoiler
</div>
<div class="quotecontent">
<div class="bbcm_spoiler_noscript"><blockquote>
Mã nguồn PHP:
[color=#000000]
package basic[/color][color=#007700]; [/color][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]scanner[/color][color=#007700]; public class [/color][color=#0000bb]sumofmatrices [/color][color=#007700]{ private static [/color][color=#0000bb]scanner scanner [/color][color=#007700]= new [/color][color=#0000bb]scanner[/color][color=#007700]( [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]in [/color][color=#007700]); public class [/color][color=#0000bb]matrix [/color][color=#007700]{ private [/color][color=#0000bb]int[/color][color=#007700][][] [/color][color=#0000bb]matrix[/color][color=#007700]; private [/color][color=#0000bb]int row[/color][color=#007700]; private [/color][color=#0000bb]int column[/color][color=#007700]; [/color][color=#ff8000]// constructor [/color][color=#007700]public [/color][color=#0000bb]matrix[/color][color=#007700]() { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print( [/color][color=#dd0000]"enter number of row and column
" [/color][color=#007700]); [/color][color=#0000bb]boolean continueloop [/color][color=#007700]= [/color][color=#0000bb]true[/color][color=#007700]; while( [/color][color=#0000bb]continueloop [/color][color=#007700]) { try { [/color][color=#0000bb]row [/color][color=#007700]= [/color][color=#0000bb]inputhandling[/color][color=#007700]( [/color][color=#dd0000]"row" [/color][color=#007700]); [/color][color=#0000bb]column [/color][color=#007700]= [/color][color=#0000bb]inputhandling[/color][color=#007700]( [/color][color=#dd0000]"column" [/color][color=#007700]); if ( [/color][color=#0000bb]row [/color][color=#007700]<= [/color][color=#0000bb]0 [/color][color=#007700]|| [/color][color=#0000bb]column [/color][color=#007700]<= [/color][color=#0000bb]0 [/color][color=#007700]) throw new [/color][color=#0000bb]illegalargumentexception[/color][color=#007700]( [/color][color=#dd0000]"row or column cannot have negative value" [/color][color=#007700]); else [/color][color=#0000bb]continueloop [/color][color=#007700]= [/color][color=#0000bb]false[/color][color=#007700]; } catch ( [/color][color=#0000bb]exception e [/color][color=#007700]) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]( [/color][color=#0000bb]e [/color][color=#007700]); } } [/color][color=#0000bb]matrix [/color][color=#007700]= new [/color][color=#0000bb]int[/color][color=#007700][ [/color][color=#0000bb]row [/color][color=#007700]][ [/color][color=#0000bb]column [/color][color=#007700]]; } [/color][color=#ff8000]// constructor with argument [/color][color=#007700]public [/color][color=#0000bb]matrix[/color][color=#007700]( [/color][color=#0000bb]int row[/color][color=#007700], [/color][color=#0000bb]int column [/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]row [/color][color=#007700]= [/color][color=#0000bb]row[/color][color=#007700]; [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]column [/color][color=#007700]= [/color][color=#0000bb]column[/color][color=#007700]; [/color][color=#0000bb]matrix [/color][color=#007700]= new [/color][color=#0000bb]int[/color][color=#007700][ [/color][color=#0000bb]row [/color][color=#007700]][ [/color][color=#0000bb]column [/color][color=#007700]]; } public [/color][color=#0000bb]int getrow[/color][color=#007700]() { return [/color][color=#0000bb]row[/color][color=#007700]; } public [/color][color=#0000bb]int getcolumn[/color][color=#007700]() { return [/color][color=#0000bb]column[/color][color=#007700]; } [/color][color=#ff8000]// enter value of each elements of matrix [/color][color=#007700]public [/color][color=#0000bb]void passingvalue[/color][color=#007700]() { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print( [/color][color=#dd0000]"enter value for each element of matrix
" [/color][color=#007700]); for ( [/color][color=#0000bb]int i [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]i [/color][color=#007700]< [/color][color=#0000bb]row[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++ ) for ( [/color][color=#0000bb]int j [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]j [/color][color=#007700]< [/color][color=#0000bb]column[/color][color=#007700]; [/color][color=#0000bb]j[/color][color=#007700]++ ) { [/color][color=#0000bb]matrix[/color][color=#007700][ [/color][color=#0000bb]i [/color][color=#007700]][ [/color][color=#0000bb]j [/color][color=#007700]] = [/color][color=#0000bb]inputhandling[/color][color=#007700]( [/color][color=#dd0000]"[" [/color][color=#007700]+ [/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#dd0000]"][" [/color][color=#007700]+ [/color][color=#0000bb]j [/color][color=#007700]+ [/color][color=#dd0000]"]" [/color][color=#007700]); } } public [/color][color=#0000bb]void display[/color][color=#007700]() { for ( [/color][color=#0000bb]int i [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]i [/color][color=#007700]< [/color][color=#0000bb]row[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++ ) { for ( [/color][color=#0000bb]int j [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]j [/color][color=#007700]< [/color][color=#0000bb]column[/color][color=#007700]; [/color][color=#0000bb]j[/color][color=#007700]++ ) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]printf[/color][color=#007700]( [/color][color=#dd0000]"%d "[/color][color=#007700], [/color][color=#0000bb]matrix[/color][color=#007700][ [/color][color=#0000bb]i [/color][color=#007700]][ [/color][color=#0000bb]j [/color][color=#007700]] ); } [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700](); } [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700](); } } [/color][color=#ff8000]// ensure the entered value is a integer [/color][color=#007700]private static [/color][color=#0000bb]int inputhandling[/color][color=#007700]( [/color][color=#0000bb]string str [/color][color=#007700]) { [/color][color=#0000bb]boolean continueloop [/color][color=#007700]= [/color][color=#0000bb]true[/color][color=#007700]; [/color][color=#0000bb]int result [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700]; while( [/color][color=#0000bb]continueloop [/color][color=#007700]) { try { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print( [/color][color=#0000bb]str [/color][color=#007700]+ [/color][color=#dd0000]":\t" [/color][color=#007700]); [/color][color=#0000bb]result [/color][color=#007700]= [/color][color=#0000bb]integer[/color][color=#007700].[/color][color=#0000bb]parseint[/color][color=#007700]( [/color][color=#0000bb]scanner[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]() ); [/color][color=#0000bb]continueloop [/color][color=#007700]= [/color][color=#0000bb]false[/color][color=#007700]; } catch ( [/color][color=#0000bb]exception e [/color][color=#007700]) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]( [/color][color=#dd0000]"value is invalid! please enter again" [/color][color=#007700]); } } return [/color][color=#0000bb]result[/color][color=#007700]; } [/color][color=#ff8000]// method to plus two matrices [/color][color=#007700]public static [/color][color=#0000bb]matrix addition[/color][color=#007700]( [/color][color=#0000bb]sumofmatrices temp[/color][color=#007700], [/color][color=#0000bb]matrix ma1[/color][color=#007700], [/color][color=#0000bb]matrix ma2 [/color][color=#007700]) [/color][color=#0000bb]throws exception [/color][color=#007700]{ if ( [/color][color=#0000bb]ma1[/color][color=#007700].[/color][color=#0000bb]row [/color][color=#007700]!= [/color][color=#0000bb]ma2[/color][color=#007700].[/color][color=#0000bb]row [/color][color=#007700]|| [/color][color=#0000bb]ma1[/color][color=#007700].[/color][color=#0000bb]column [/color][color=#007700]!= [/color][color=#0000bb]ma2[/color][color=#007700].[/color][color=#0000bb]column [/color][color=#007700]) { throw new [/color][color=#0000bb]exception[/color][color=#007700]( [/color][color=#dd0000]"rows or column of two matrices aren't equal. operation plus cannot be processed." [/color][color=#007700]); } else { [/color][color=#0000bb]int numberofrow [/color][color=#007700]= [/color][color=#0000bb]ma1[/color][color=#007700].[/color][color=#0000bb]row[/color][color=#007700], [/color][color=#0000bb]numberofcolumn [/color][color=#007700]= [/color][color=#0000bb]ma1[/color][color=#007700].[/color][color=#0000bb]column[/color][color=#007700]; [/color][color=#0000bb]matrix result [/color][color=#007700]= [/color][color=#0000bb]temp[/color][color=#007700].new [/color][color=#0000bb]matrix[/color][color=#007700]( [/color][color=#0000bb]numberofrow[/color][color=#007700], [/color][color=#0000bb]numberofcolumn [/color][color=#007700]); for ( [/color][color=#0000bb]int i [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]i [/color][color=#007700]< [/color][color=#0000bb]numberofrow[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++ ) for ( [/color][color=#0000bb]int j [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]j [/color][color=#007700]< [/color][color=#0000bb]numberofcolumn[/color][color=#007700]; [/color][color=#0000bb]j[/color][color=#007700]++ ) { [/color][color=#0000bb]result[/color][color=#007700].[/color][color=#0000bb]matrix[/color][color=#007700][ [/color][color=#0000bb]i [/color][color=#007700]][ [/color][color=#0000bb]j [/color][color=#007700]] = [/color][color=#0000bb]ma1[/color][color=#007700].[/color][color=#0000bb]matrix[/color][color=#007700][ [/color][color=#0000bb]i [/color][color=#007700]][ [/color][color=#0000bb]j [/color][color=#007700]] + [/color][color=#0000bb]ma2[/color][color=#007700].[/color][color=#0000bb]matrix[/color][color=#007700][ [/color][color=#0000bb]i [/color][color=#007700]][ [/color][color=#0000bb]j [/color][color=#007700]]; } return [/color][color=#0000bb]result[/color][color=#007700]; } } public static [/color][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]args[/color][color=#007700]) { [/color][color=#0000bb]sumofmatrices newtest [/color][color=#007700]= new [/color][color=#0000bb]sumofmatrices[/color][color=#007700](); [/color][color=#0000bb]matrix ma1 [/color][color=#007700]= [/color][color=#0000bb]newtest[/color][color=#007700].new [/color][color=#0000bb]matrix[/color][color=#007700](); [/color][color=#0000bb]ma1[/color][color=#007700].[/color][color=#0000bb]passingvalue[/color][color=#007700](); [/color][color=#0000bb]ma1[/color][color=#007700].[/color][color=#0000bb]display[/color][color=#007700](); [/color][color=#0000bb]matrix ma2 [/color][color=#007700]= [/color][color=#0000bb]newtest[/color][color=#007700].new [/color][color=#0000bb]matrix[/color][color=#007700](); [/color][color=#0000bb]ma2[/color][color=#007700].[/color][color=#0000bb]passingvalue[/color][color=#007700](); [/color][color=#0000bb]ma2[/color][color=#007700].[/color][color=#0000bb]display[/color][color=#007700](); [/color][color=#0000bb]matrix ma3[/color][color=#007700]; try { [/color][color=#0000bb]ma3 [/color][color=#007700]= [/color][color=#0000bb]addition[/color][color=#007700]( [/color][color=#0000bb]newtest[/color][color=#007700], [/color][color=#0000bb]ma1[/color][color=#007700], [/color][color=#0000bb]ma2 [/color][color=#007700]); [/color][color=#0000bb]ma3[/color][color=#007700].[/color][color=#0000bb]display[/color][color=#007700](); } catch ([/color][color=#0000bb]exception e[/color][color=#007700]) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]err[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]( [/color][color=#0000bb]e [/color][color=#007700]); } } }[/color]
</blockquote></div>
</div>
</div>
Khu dự án Diamond Alnata Plus phát triển bởi Gamuda Land thiết kế hợp lý nằm trung tâm thông gió tự nhiên. Diamond Alnata Plus Tân Phú thiết kế hợp lý sống đích thực ngay giữa trung tâm. Căn hộ cách...
Khu dự án Diamond Alnata Plus giáp trung tâm