Chủ đề: Bài 9: Mảng trong Java!
-
02-15-2014, 07:00 AM #51Junior Member
- Ngày tham gia
- Mar 2015
- Bài viết
- 0
- package baitap;
- import java.util.scanner;
- public class bai1 {
- public static void main(string[] args) {
- int a, i;
- scanner nhapdulieu = new scanner(system.in);
- system.out.print("so sinh vien: ");
- a = nhapdulieu.nextint();
- nhapdulieu.nextline();
- string arrstring[] = new string[a];
- if (a > 0) {
- for (i = 0; i < a; i++) {
- system.out.println("nhap ten sinh vien thu " +i);
- arrstring[i] = nhapdulieu.nextline();
- }
- system.out.println("nhap ten sinh vien can tim ");
- string ten = nhapdulieu.nextline();
- int x=0;
- for(i=0;i<a;i++)
- {
- if(ten.equals(arrstring[i]))
- x=x+1;
- }
- if(x>0)
- system.out.println("ten "+ten+" co trong danh sach");
- else
- system.out.println("ten "+ten+" khong co trong danh sach");
- }
- else{
- system.out.println("nhap so sinh vien lon hon 0");
- }
- }
- }
-
02-21-2014, 07:00 AM #52Junior Member
- Ngày tham gia
- Apr 2016
- Bài viết
- 0
bai 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ã:import java.util.arrays; import java.util.scanner; public class bai1 { public static void main(string[] args) { timkiem(); } public static int nhapsosv() { system.out.print("so sv: "); scanner input = new scanner(system.in); boolean check = true; int n = 0; while (check) { try { n = input.nextint(); if (n > 0) { check = false; } else { system.out.println("so luong sv phai >0, nhap lai!"); input.nextline(); } } catch (exception e) { system.out.println("so sv phai la so nguyen, nhap lai!"); input.nextline(); } } return n; } public static string[] nhapdanhsach() { scanner input = new scanner(system.in); int n = nhapsosv(); system.out.println("nhap ho va ten sv:"); string[] hoten = new string[n]; int i = 0; while (i < n) { system.out.print(i + 1 + ". "); hoten[i] = xoaspace(input.nextline()); i++; } return hoten; } public static void timkiem() { scanner input = new scanner(system.in); string[] hoten = nhapdanhsach(); system.out.print("nhap ten sv can tim: "); string ten = xoaspace(input.nextline()); system.out.println(); int chiso = arrays.aslist(hoten).indexof(ten); if (chiso != -1) { system.out.println("note: sinh vien \"" + ten + "\" co trong danh sach, stt: " + (chiso + 1)); } else { system.out.println("note: sinh vien \"" + ten + "\" khong co trong danh sach!"); } } public static string xoaspace(string str) { str = str.replaceall("\\s+", " "); str = str.replaceall("^\\s+|\\s+$", ""); return str; } }
</div>
</div>
bai 2:
<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ã:import java.util.arrays; import java.util.scanner; public class bai2 { public static void main(string[] args) { sapxep(); } public static int nhapso() { int n = 0; scanner input = new scanner(system.in); boolean check = true; while (check) { try { n = input.nextint(); check = false; } catch (exception e) { system.out.println("chi duoc nhap so, nhap lai!"); input.nextline(); } } return n; } public static int[] nhapdayso() { system.out.print("so phan tu cua day so: "); int n = nhapso(); system.out.println("nhap day so: "); int[] dayso = new int[n]; int i = 0; while (i < n) { dayso[i] = nhapso(); i++; } return dayso; } public static void sapxep() { int[] dayso=nhapdayso(); system.out.println("day so da sap xep la:"); arrays.sort(dayso); for(int i=0;i<dayso.length;i++){ system.out.println(dayso[i]); } } }
</div>
</div>
bai 3:
<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ã:import java.util.scanner; public class bai3 { public static void main(string[] args) { congmatran(); } public static int nhapkichco() { int n = 0; scanner input = new scanner(system.in); boolean check = true; while (check) { try { n = input.nextint(); if (n < 0) { system.out.println("kich thuong mang phai la so >0, nhap lai!"); input.nextline(); } else { check = false; } } catch (exception e) { system.out.println("chi duoc nhap so, nhap lai!"); input.nextline(); } } return n; } public static int nhapaij() { int n = 0; scanner input = new scanner(system.in); boolean check = true; while (check) { try { n = input.nextint(); check = false; } catch (exception e) { system.out.println("chi duoc nhap so, nhap lai!"); input.nextline(); } } return n; } public static int[][] nhapmatran(int m, int n) { int[][] matran = new int[m][n]; int i = 0; while (i < m) { int j = 0; while (j < n) { system.out.print("a[" + i + "][" + j + "]: "); matran[i][j] = nhapaij(); j++; } system.out.println(); i++; } return matran; } public static void congmatran() { system.out.print("nhap so hang: "); int m = nhapkichco(); system.out.print("nhap so cot: "); int n = nhapkichco(); system.out.println("nhap ma tran 1: "); int[][] matran1 = nhapmatran(m, n); system.out.println("nhap ma tran 2: "); int[][] matran2 = nhapmatran(m, n); system.out.println(" tong 2 ma tran la:"); int i = 0; while (i < m) { int j = 0; while (j < n) { system.out.print((matran1[i][j] + matran2[i][j] + " ")); j++; } system.out.println(); i++; } } }
</div>
</div>
-
03-01-2014, 07:00 AM #53Junior Member
- Ngày tham gia
- Jan 2015
- Bài viết
- 0
mọi người ơi xem giúp mình bài 3 tại sao lại báo lỗi ở dòng code cuối cùng này với. thank nhiều!
bài 3:
<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 javabasic[/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]manghaichieu[/color][color=#007700]{ public static [/color][color=#0000bb]int nhap[/color][color=#007700](){ [/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]); [/color][color=#0000bb]boolean bl[/color][color=#007700]=[/color][color=#0000bb]false[/color][color=#007700]; [/color][color=#0000bb]int n[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700]; while(![/color][color=#0000bb]bl[/color][color=#007700]){ try{ [/color][color=#0000bb]n[/color][color=#007700]=[/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]bl[/color][color=#007700]=[/color][color=#0000bb]true[/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]"moi ban nhap lai:"[/color][color=#007700]); [/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); } } return([/color][color=#0000bb]n[/color][color=#007700]); } public static [/color][color=#0000bb]void matrana[/color][color=#007700]([/color][color=#0000bb]int m[/color][color=#007700],[/color][color=#0000bb]int n[/color][color=#007700]){ [/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]); [/color][color=#0000bb]int [/color][color=#007700][][][/color][color=#0000bb]mta[/color][color=#007700]=new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]m[/color][color=#007700]][[/color][color=#0000bb]n[/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]"+cac phan tu cua ma tran a:"[/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]m[/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]n[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"a("[/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]); [/color][color=#0000bb]mta[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]nhap[/color][color=#007700](); } } for([/color][color=#0000bb]int k[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700];[/color][color=#0000bb]k[/color][color=#007700]<[/color][color=#0000bb]m[/color][color=#007700];[/color][color=#0000bb]k[/color][color=#007700]++){ for([/color][color=#0000bb]int l[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700];[/color][color=#0000bb]l[/color][color=#007700]<[/color][color=#0000bb]n[/color][color=#007700];[/color][color=#0000bb]l[/color][color=#007700]++){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]" "[/color][color=#007700]+[/color][color=#0000bb]mta[/color][color=#007700][[/color][color=#0000bb]k[/color][color=#007700]][[/color][color=#0000bb]l[/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](); } } public static [/color][color=#0000bb]void matranb[/color][color=#007700]([/color][color=#0000bb]int m[/color][color=#007700],[/color][color=#0000bb]int n[/color][color=#007700]){ [/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]); [/color][color=#0000bb]int [/color][color=#007700][][][/color][color=#0000bb]mtb[/color][color=#007700]=new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]m[/color][color=#007700]][[/color][color=#0000bb]n[/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]"+cac phan tu cua ma tran b:"[/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]m[/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]n[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"a("[/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]); [/color][color=#0000bb]mtb[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]nhap[/color][color=#007700](); } } for([/color][color=#0000bb]int k[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700];[/color][color=#0000bb]k[/color][color=#007700]<[/color][color=#0000bb]m[/color][color=#007700];[/color][color=#0000bb]k[/color][color=#007700]++){ for([/color][color=#0000bb]int l[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700];[/color][color=#0000bb]l[/color][color=#007700]<[/color][color=#0000bb]n[/color][color=#007700];[/color][color=#0000bb]l[/color][color=#007700]++){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]" "[/color][color=#007700]+[/color][color=#0000bb]mtb[/color][color=#007700][[/color][color=#0000bb]k[/color][color=#007700]][[/color][color=#0000bb]l[/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](); } } public static [/color][color=#0000bb]void tonghaimatran[/color][color=#007700]([/color][color=#0000bb]int [/color][color=#007700][][][/color][color=#0000bb]mta[/color][color=#007700],[/color][color=#0000bb]int [/color][color=#007700][][][/color][color=#0000bb]mtb[/color][color=#007700],[/color][color=#0000bb]int [/color][color=#007700][][][/color][color=#0000bb]mtc[/color][color=#007700],[/color][color=#0000bb]int m[/color][color=#007700],[/color][color=#0000bb]int n[/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]"+tong cua hai ma tran:"[/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]m[/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]n[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ [/color][color=#0000bb]mtc[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]mta[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]+[/color][color=#0000bb]mtb[/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].print([/color][color=#dd0000]" "[/color][color=#007700]+[/color][color=#0000bb]mtc[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]+[/color][color=#dd0000]"\t"[/color][color=#007700]); } [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/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]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"+kich co cua hai ma tran:"[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]" +so hang:"[/color][color=#007700]); [/color][color=#0000bb]int m[/color][color=#007700]=[/color][color=#0000bb]nhap[/color][color=#007700](); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]" +so cot:"[/color][color=#007700]); [/color][color=#0000bb]int n[/color][color=#007700]=[/color][color=#0000bb]nhap[/color][color=#007700](); [/color][color=#0000bb]matrana[/color][color=#007700]([/color][color=#0000bb]m[/color][color=#007700],[/color][color=#0000bb]n[/color][color=#007700]); [/color][color=#0000bb]matranb[/color][color=#007700]([/color][color=#0000bb]m[/color][color=#007700],[/color][color=#0000bb]n[/color][color=#007700]); [/color][color=#0000bb]tonghaimatran[/color][color=#007700]([/color][color=#0000bb]mta[/color][color=#007700],[/color][color=#0000bb]mtb[/color][color=#007700],[/color][color=#0000bb]mtc[/color][color=#007700],[/color][color=#0000bb]m[/color][color=#007700],[/color][color=#0000bb]n[/color][color=#007700]); }}[/color]
</div>
</div>
-
03-01-2014, 07:00 AM #54Junior Member
- Ngày tham gia
- Mar 2014
- Bài viết
- 0
bai 2:
<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 javabasic[/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]sapxepmang [/color][color=#007700]{ public static [/color][color=#0000bb]int nhap[/color][color=#007700](){ [/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]); [/color][color=#0000bb]boolean bl[/color][color=#007700]=[/color][color=#0000bb]false[/color][color=#007700]; [/color][color=#0000bb]int n[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700]; while(![/color][color=#0000bb]bl[/color][color=#007700]){ try{ [/color][color=#0000bb]n[/color][color=#007700]=[/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]bl[/color][color=#007700]=[/color][color=#0000bb]true[/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]"moi ban nhap so:"[/color][color=#007700]); [/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); } } return([/color][color=#0000bb]n[/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]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"ban muon nhap mot day co bao nhieu so?"[/color][color=#007700]); [/color][color=#0000bb]int s[/color][color=#007700]=[/color][color=#0000bb]nhap[/color][color=#007700](); [/color][color=#0000bb]int [/color][color=#007700][][/color][color=#0000bb]dayso[/color][color=#007700]=new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]s[/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]"moi ban nhap cac so nguyen cua day:"[/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]s[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]++){ [/color][color=#0000bb]dayso[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]=[/color][color=#0000bb]nhap[/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]s[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ for([/color][color=#0000bb]int k[/color][color=#007700]=[/color][color=#0000bb]j[/color][color=#007700]+[/color][color=#0000bb]1[/color][color=#007700];[/color][color=#0000bb]k[/color][color=#007700]<=[/color][color=#0000bb]s[/color][color=#007700]-[/color][color=#0000bb]1[/color][color=#007700];[/color][color=#0000bb]k[/color][color=#007700]++){ if([/color][color=#0000bb]dayso[/color][color=#007700][[/color][color=#0000bb]k[/color][color=#007700]]<=[/color][color=#0000bb]dayso[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]){ [/color][color=#0000bb]int hv[/color][color=#007700]=[/color][color=#0000bb]dayso[/color][color=#007700][[/color][color=#0000bb]k[/color][color=#007700]]; [/color][color=#0000bb]dayso[/color][color=#007700][[/color][color=#0000bb]k[/color][color=#007700]]=[/color][color=#0000bb]dayso[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]; [/color][color=#0000bb]dayso[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]hv[/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]"thu tu tang dan cua day:"[/color][color=#007700]); for([/color][color=#0000bb]int l[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700];[/color][color=#0000bb]l[/color][color=#007700]<[/color][color=#0000bb]s[/color][color=#007700];[/color][color=#0000bb]l[/color][color=#007700]++) [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#0000bb]dayso[/color][color=#007700][[/color][color=#0000bb]l[/color][color=#007700]]+[/color][color=#dd0000]","[/color][color=#007700]); }}[/color]
</div>
</div>
-
03-01-2014, 07:00 AM #55Junior Member
- Ngày tham gia
- Jul 2015
- Bài viết
- 0
bai 3:
<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 javabasic[/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]manghaichieu[/color][color=#007700]{ public static [/color][color=#0000bb]int nhap[/color][color=#007700](){ [/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]); [/color][color=#0000bb]boolean bl[/color][color=#007700]=[/color][color=#0000bb]false[/color][color=#007700]; [/color][color=#0000bb]int n[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700]; while(![/color][color=#0000bb]bl[/color][color=#007700]){ try{ [/color][color=#0000bb]n[/color][color=#007700]=[/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]bl[/color][color=#007700]=[/color][color=#0000bb]true[/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]"moi ban nhap lai:"[/color][color=#007700]); [/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); } } return([/color][color=#0000bb]n[/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]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"+kich co cua hai ma tran:"[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]" +so hang:"[/color][color=#007700]); [/color][color=#0000bb]int m[/color][color=#007700]=[/color][color=#0000bb]nhap[/color][color=#007700](); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]" +so cot:"[/color][color=#007700]); [/color][color=#0000bb]int n[/color][color=#007700]=[/color][color=#0000bb]nhap[/color][color=#007700](); [/color][color=#0000bb]int [/color][color=#007700][][][/color][color=#0000bb]mta[/color][color=#007700]=new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]m[/color][color=#007700]][[/color][color=#0000bb]n[/color][color=#007700]]; [/color][color=#0000bb]int [/color][color=#007700][][][/color][color=#0000bb]mtc[/color][color=#007700]=new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]m[/color][color=#007700]][[/color][color=#0000bb]n[/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]"+cac phan tu cua ma tran a:"[/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]m[/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]n[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"a("[/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]); [/color][color=#0000bb]mta[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]nhap[/color][color=#007700](); } } for([/color][color=#0000bb]int k[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700];[/color][color=#0000bb]k[/color][color=#007700]<[/color][color=#0000bb]m[/color][color=#007700];[/color][color=#0000bb]k[/color][color=#007700]++){ for([/color][color=#0000bb]int l[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700];[/color][color=#0000bb]l[/color][color=#007700]<[/color][color=#0000bb]n[/color][color=#007700];[/color][color=#0000bb]l[/color][color=#007700]++){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]" "[/color][color=#007700]+[/color][color=#0000bb]mta[/color][color=#007700][[/color][color=#0000bb]k[/color][color=#007700]][[/color][color=#0000bb]l[/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=#0000bb]int [/color][color=#007700][][][/color][color=#0000bb]mtb[/color][color=#007700]=new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]m[/color][color=#007700]][[/color][color=#0000bb]n[/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]"+cac phan tu cua ma tran b:"[/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]m[/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]n[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"a("[/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]); [/color][color=#0000bb]mtb[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]nhap[/color][color=#007700](); } } for([/color][color=#0000bb]int k[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700];[/color][color=#0000bb]k[/color][color=#007700]<[/color][color=#0000bb]m[/color][color=#007700];[/color][color=#0000bb]k[/color][color=#007700]++){ for([/color][color=#0000bb]int l[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700];[/color][color=#0000bb]l[/color][color=#007700]<[/color][color=#0000bb]n[/color][color=#007700];[/color][color=#0000bb]l[/color][color=#007700]++){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]" "[/color][color=#007700]+[/color][color=#0000bb]mtb[/color][color=#007700][[/color][color=#0000bb]k[/color][color=#007700]][[/color][color=#0000bb]l[/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=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"+tong cua hai ma tran:"[/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]m[/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]n[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ [/color][color=#0000bb]mtc[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]mta[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]+[/color][color=#0000bb]mtb[/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].print([/color][color=#dd0000]" "[/color][color=#007700]+[/color][color=#0000bb]mtc[/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]
</div>
</div>
-
04-05-2014, 07:00 AM #56Junior Member
- Ngày tham gia
- Apr 2015
- Bài viết
- 9
bắt đầu từ bài này ad cho bài tập căng quá, e chả biết làm sao cả
-
04-06-2014, 07:00 AM #57Junior Member
- Ngày tham gia
- Nov 2015
- Bài viết
- 0
Mã nguồn PHP:[color=#000000]
import java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]scanner[/color][color=#007700];[/color][color=#ff8000]/**** @author thanh*/[/color][color=#007700]public class [/color][color=#0000bb]cau1 [/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]int a[/color][color=#007700], [/color][color=#0000bb]i[/color][color=#007700]; [/color][color=#0000bb]scanner duc [/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]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"số sinh viên: "[/color][color=#007700]); [/color][color=#0000bb]a [/color][color=#007700]= [/color][color=#0000bb]duc[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]duc[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); [/color][color=#0000bb]string arr[/color][color=#007700][] = new [/color][color=#0000bb]string[/color][color=#007700][[/color][color=#0000bb]a[/color][color=#007700]]; if([/color][color=#0000bb]a[/color][color=#007700]>[/color][color=#0000bb]0[/color][color=#007700]){ for([/color][color=#0000bb]i[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]<[/color][color=#0000bb]a[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]++){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập tên sinh viên thứ "[/color][color=#007700]+([/color][color=#0000bb]i[/color][color=#007700]+[/color][color=#0000bb]1[/color][color=#007700])+[/color][color=#dd0000]" : "[/color][color=#007700]); [/color][color=#0000bb]arr[/color][color=#007700][[/color][color=#0000bb]a[/color][color=#007700]]=[/color][color=#0000bb]duc[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); } [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập tên sinh viên cần tìm: "[/color][color=#007700]); [/color][color=#0000bb]string ten [/color][color=#007700]= [/color][color=#0000bb]duc[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); [/color][color=#0000bb]int x[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700]; for([/color][color=#0000bb]i[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]<[/color][color=#0000bb]a[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]++) { if([/color][color=#0000bb]ten[/color][color=#007700].[/color][color=#0000bb]equals[/color][color=#007700]([/color][color=#0000bb]arr[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]])) [/color][color=#0000bb]x[/color][color=#007700]=[/color][color=#0000bb]x[/color][color=#007700]+[/color][color=#0000bb]1[/color][color=#007700]; } if([/color][color=#0000bb]x[/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]"tên "[/color][color=#007700]+[/color][color=#0000bb]ten[/color][color=#007700]+[/color][color=#dd0000]" có trong danh sách"[/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]"tên "[/color][color=#007700]+[/color][color=#0000bb]ten[/color][color=#007700]+[/color][color=#dd0000]" không có trong danh sách"[/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]"nhập số sinh viên lớn hơn 0"[/color][color=#007700]); } }}[/color]
-
04-08-2014, 07:00 AM #58Banned
- Ngày tham gia
- Apr 2014
- Bài viết
- 0
Gửi bởi try_again
Mã nguồn PHP:[color=#000000]
nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); [/color][color=#0000bb]string arrstring[/color][color=#007700][] = new [/color][color=#0000bb]string[/color][color=#007700][[/color][color=#0000bb]a[/color][color=#007700]];[/color]
bạn có thể giải thích cho mình vs đc ko
-
05-05-2014, 07:00 AM #59Junior Member
- Ngày tham gia
- Aug 2015
- Bài viết
- 0
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 javacoban[/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=#ff8000]/**** @author admin*/[/color][color=#007700]public class [/color][color=#0000bb]bai9_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]int sinhvien[/color][color=#007700], [/color][color=#0000bb]i[/color][color=#007700]; [/color][color=#0000bb]string tim[/color][color=#007700]; [/color][color=#0000bb]boolean kq [/color][color=#007700]= [/color][color=#0000bb]false[/color][color=#007700]; [/color][color=#0000bb]scanner nhapdulieu [/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]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập số sinh viên: "[/color][color=#007700]); [/color][color=#0000bb]sinhvien [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); [/color][color=#0000bb]string hoten[/color][color=#007700][] = new [/color][color=#0000bb]string[/color][color=#007700][[/color][color=#0000bb]sinhvien[/color][color=#007700]];[/color][color=#ff8000]//khai báo mảng và cấp phát bộ nhớ cho mảng [/color][color=#007700]for([/color][color=#0000bb]i [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]i [/color][color=#007700]< [/color][color=#0000bb]sinhvien[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập họ tên sinh viên " [/color][color=#007700]+ [/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#dd0000]": "[/color][color=#007700]); [/color][color=#0000bb]hoten[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]] = [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextline[/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]"nhập tên sinh viên muốn tìm: "[/color][color=#007700]); [/color][color=#0000bb]tim [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); for([/color][color=#0000bb]i [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]i [/color][color=#007700]< [/color][color=#0000bb]sinhvien[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++) { [/color][color=#0000bb]kq [/color][color=#007700]= [/color][color=#0000bb]tim[/color][color=#007700].[/color][color=#0000bb]equals[/color][color=#007700]([/color][color=#0000bb]hoten[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]); } if([/color][color=#0000bb]kq [/color][color=#007700]== [/color][color=#0000bb]true[/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]"tìm thấy tên " [/color][color=#007700]+ [/color][color=#0000bb]tim[/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]"không tìm thấy tên " [/color][color=#007700]+ [/color][color=#0000bb]tim[/color][color=#007700]); } }}[/color]
</div>
</div>
bài 2:
<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 javacoban[/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=#ff8000]/**** @author admin*/[/color][color=#007700]public class [/color][color=#0000bb]newclass [/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]int a[/color][color=#007700], [/color][color=#0000bb]i[/color][color=#007700], [/color][color=#0000bb]j[/color][color=#007700], [/color][color=#0000bb]temp[/color][color=#007700]; [/color][color=#0000bb]scanner nhapdulieu [/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]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập số phần tử của mảng: "[/color][color=#007700]); [/color][color=#0000bb]a [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]int b[/color][color=#007700][]; [/color][color=#ff8000]//khai báo mảng b [/color][color=#0000bb]b [/color][color=#007700]= new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]a[/color][color=#007700]]; [/color][color=#ff8000]//cấp phát mảng b có a phần tử [/color][color=#007700]for([/color][color=#0000bb]i [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]i [/color][color=#007700]< [/color][color=#0000bb]a[/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]println[/color][color=#007700]([/color][color=#dd0000]"nhập số n thứ " [/color][color=#007700]+ [/color][color=#0000bb]i[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]] = [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); } for([/color][color=#0000bb]i [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700];[/color][color=#0000bb]i [/color][color=#007700]< [/color][color=#0000bb]a[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++){ for([/color][color=#0000bb]j [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]j [/color][color=#007700]<= [/color][color=#0000bb]i [/color][color=#007700]; [/color][color=#0000bb]j[/color][color=#007700]++){ if([/color][color=#0000bb]b[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]<[/color][color=#0000bb]b[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]){ [/color][color=#0000bb]temp [/color][color=#007700]= [/color][color=#0000bb]b[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]; [/color][color=#0000bb]b[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]] = [/color][color=#0000bb]b[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]; [/color][color=#0000bb]b[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]= [/color][color=#0000bb]temp[/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]"mảng sắp xếp lại: "[/color][color=#007700]); for([/color][color=#0000bb]i [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700];[/color][color=#0000bb]i [/color][color=#007700]< [/color][color=#0000bb]a[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#0000bb]b[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]+[/color][color=#dd0000]" "[/color][color=#007700]); } }}[/color]
</div>
</div>
-
05-22-2014, 07:00 AM #60Junior Member
- Ngày tham gia
- Sep 2014
- Bài viết
- 0
Gửi bởi trần văn chiến
xuống dưới ấy
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