Trang 6 của 9 Đầu tiênĐầu tiên ... 45678 ... CuốiCuối
Kết quả 51 đến 60 của 85
  1. #51
    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");
    • }
    • }
    • }
    cho mình hỏi chỗ dòng số 10. nhapdulieu.nextline(); là sao ah. mình không thấy mối liên quan của nó trong đoạn code. mà bỏ đi thì code lại chạy lỗi.

  2. #52
    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;
        }
    }
    </blockquote></div>
    </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]);
            }
        }
     
       
    }
    </blockquote></div>
    </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++;
            }
     
        }
    }
    </blockquote></div>
    </div>
    </div>

  3. #53
    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] 
    </blockquote></div>
    </div>
    </div>

  4. #54
    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] 
    </blockquote></div>
    </div>
    </div>

  5. #55
    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] 
    </blockquote></div>
    </div>
    </div>

  6. #56
    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ả

  7. #57
    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] 

  8. #58
    Ngày tham gia
    Apr 2014
    Bài viết
    0
    Trích dẫn Gửi bởi try_again
    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 baitap[/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]bai1 [/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 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]"so sinh vien: "[/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]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]]; 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].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhap ten sinh vien thu " [/color][color=#007700]+[/color][color=#0000bb]i[/color][color=#007700]); [/color][color=#0000bb]arrstring[/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]"nhap ten sinh vien can tim "[/color][color=#007700]); [/color][color=#0000bb]string ten [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/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]arrstring[/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]"ten "[/color][color=#007700]+[/color][color=#0000bb]ten[/color][color=#007700]+[/color][color=#dd0000]" co trong danh sach"[/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]"ten "[/color][color=#007700]+[/color][color=#0000bb]ten[/color][color=#007700]+[/color][color=#dd0000]" khong co trong danh sach"[/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]"nhap so sinh vien lon hon 0"[/color][color=#007700]); } }}[/color] 
    </blockquote></div>
    </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 baitap[/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]bai2 [/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 n[/color][color=#007700], [/color][color=#0000bb]k[/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].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhap so phan tu can nhap "[/color][color=#007700]); [/color][color=#0000bb]n [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]int arrint[/color][color=#007700][] = new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]n[/color][color=#007700]]; if([/color][color=#0000bb]n[/color][color=#007700]>[/color][color=#0000bb]0[/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]n[/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]"nhap phan tu thu " [/color][color=#007700]+[/color][color=#0000bb]i[/color][color=#007700]); [/color][color=#0000bb]arrint[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]] = [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextint[/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]"day so vua nhap la " [/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]n[/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]arrint[/color][color=#007700][[/color][color=#0000bb]i[/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](); 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]n [/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]n[/color][color=#007700]; [/color][color=#0000bb]j[/color][color=#007700]++) { if ([/color][color=#0000bb]arrint[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]] > [/color][color=#0000bb]arrint[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]) { [/color][color=#0000bb]k [/color][color=#007700]= [/color][color=#0000bb]arrint[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]; [/color][color=#0000bb]arrint[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]] = [/color][color=#0000bb]arrint[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]; [/color][color=#0000bb]arrint[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]] = [/color][color=#0000bb]k[/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]"day so sau khi duoc sap xep la "[/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]n[/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]arrint[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]+[/color][color=#dd0000]" "[/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]"so phan tu nhap khong hop le"[/color][color=#007700]); }}[/color] 
    </blockquote></div>
    </div>
    </div>


    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 baitap[/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]bai3 [/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[/color][color=#007700][][] [/color][color=#0000bb]arrint1[/color][color=#007700]; [/color][color=#0000bb]int[/color][color=#007700][][] [/color][color=#0000bb]arrint2[/color][color=#007700]; [/color][color=#0000bb]int n[/color][color=#007700], [/color][color=#0000bb]m[/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]"nhap so hang "[/color][color=#007700]); [/color][color=#0000bb]n [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhap so cot "[/color][color=#007700]); [/color][color=#0000bb]m [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]arrint1 [/color][color=#007700]= new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]n[/color][color=#007700]][[/color][color=#0000bb]m[/color][color=#007700]]; [/color][color=#0000bb]arrint2 [/color][color=#007700]= new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]n[/color][color=#007700]][[/color][color=#0000bb]m[/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]"nhap ma tran 1"[/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]n[/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]m[/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]"nhap phan tu hang " [/color][color=#007700]+ [/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#dd0000]" cot " [/color][color=#007700]+ [/color][color=#0000bb]j[/color][color=#007700]+[/color][color=#dd0000]" "[/color][color=#007700]); [/color][color=#0000bb]arrint1[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]] = [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextint[/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]"nhap ma tran 2"[/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]n[/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]m[/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]"nhap phan tu hang " [/color][color=#007700]+ [/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#dd0000]" cot " [/color][color=#007700]+ [/color][color=#0000bb]j[/color][color=#007700]+[/color][color=#dd0000]" "[/color][color=#007700]); [/color][color=#0000bb]arrint2[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]] = [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextint[/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]"ma tran 1 vua nhap "[/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]n[/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]m[/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=#0000bb]arrint1[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/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]"ma tran 2 vua nhap "[/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]n[/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]m[/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=#0000bb]arrint2[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/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 2 ma tran vua nhap la "[/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]n[/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]m[/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=#0000bb]arrint1[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]+[/color][color=#0000bb]arrint2[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/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] 
    </blockquote></div>
    </div>
    </div>
    bạn cho mình hỏi, ở bài 1 có dòng lệnh


    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] 
    cái dòng lệnh này nếu mình bỏ đi thì chương trình ko báo lỗi và chạy vẫn được, nhưng khi nhập giá trị trong console thì nó xuất hiện cái lỗi là không cho nhập phần tử thứ 0, nó sẽ chỉ cho nhập kể từ phần tử thứ 1
    bạn có thể giải thích cho mình vs đc ko

  9. #59
    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] 
    </blockquote></div>
    </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] 
    </blockquote></div>
    </div>
    </div>

  10. #60
    Ngày tham gia
    Sep 2014
    Bài viết
    0
    Trích dẫn Gửi bởi trần văn chiến
    mình nộp bài:
    câu 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 [/color][color=#007700]array; [/color][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]io[/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]bai1 [/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]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]sinhvienlist sinhvien[/color][color=#007700]; [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhap so sinh vien: "[/color][color=#007700]); [/color][color=#0000bb]int n [/color][color=#007700]= [/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]sinhvien [/color][color=#007700]= new [/color][color=#0000bb]sinhvienlist[/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]"sinh vien vua nhap la: "[/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]sinhvien[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhap sinh vien can tim kiem: "[/color][color=#007700]); [/color][color=#0000bb]string nextline [/color][color=#007700]= [/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); [/color][color=#0000bb]string name [/color][color=#007700]= [/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); [/color][color=#0000bb]int i [/color][color=#007700]= [/color][color=#0000bb]sinhvien[/color][color=#007700].[/color][color=#0000bb]timkiem[/color][color=#007700]([/color][color=#0000bb]name[/color][color=#007700]); if([/color][color=#0000bb]i[/color][color=#007700]!= -[/color][color=#0000bb]1[/color][color=#007700]){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"sinh vien tim thay la: "[/color][color=#007700]+[/color][color=#0000bb]sinhvien[/color][color=#007700].[/color][color=#0000bb]getsinhvien[/color][color=#007700]([/color][color=#0000bb]i[/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]"khong tim thay sinh vien nay"[/color][color=#007700]); } }}class [/color][color=#0000bb]sinhvien[/color][color=#007700]{ [/color][color=#0000bb]string hoten[/color][color=#007700]; public [/color][color=#0000bb]sinhvien[/color][color=#007700](){ [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]hoten [/color][color=#007700]= [/color][color=#dd0000]""[/color][color=#007700]; } public [/color][color=#0000bb]string getname[/color][color=#007700](){ return [/color][color=#0000bb]hoten[/color][color=#007700]; } public [/color][color=#0000bb]void 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]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhap ho ten: "[/color][color=#007700]); [/color][color=#0000bb]hoten [/color][color=#007700]= [/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); } public [/color][color=#0000bb]string tostring[/color][color=#007700](){ return [/color][color=#dd0000]"ho ten: "[/color][color=#007700]+[/color][color=#0000bb]hoten[/color][color=#007700]+[/color][color=#dd0000]"
    "[/color][color=#007700]; }}class [/color][color=#0000bb]sinhvienlist[/color][color=#007700]{ [/color][color=#0000bb]sinhvien[/color][color=#007700][] [/color][color=#0000bb]sv[/color][color=#007700]; public [/color][color=#0000bb]sinhvienlist[/color][color=#007700]([/color][color=#0000bb]int size[/color][color=#007700]){ [/color][color=#0000bb]sv [/color][color=#007700]= new [/color][color=#0000bb]sinhvien[/color][color=#007700][[/color][color=#0000bb]size[/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]size[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]++){ [/color][color=#0000bb]sv[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]] = new [/color][color=#0000bb]sinhvien[/color][color=#007700](); [/color][color=#0000bb]sv[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]nhap[/color][color=#007700](); } } public [/color][color=#0000bb]string tostring[/color][color=#007700](){ [/color][color=#0000bb]string s[/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]sv[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]++){ [/color][color=#0000bb]s[/color][color=#007700]+=[/color][color=#0000bb]sv[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]; } return [/color][color=#0000bb]s[/color][color=#007700]; } public [/color][color=#0000bb]sinhvien getsinhvien[/color][color=#007700]([/color][color=#0000bb]int i[/color][color=#007700]){ return [/color][color=#0000bb]sv[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]; } public [/color][color=#0000bb]int timkiem[/color][color=#007700]([/color][color=#0000bb]string name[/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]sv[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]++){ if([/color][color=#0000bb]sv[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]getname[/color][color=#007700]().[/color][color=#0000bb]equalsignorecase[/color][color=#007700]([/color][color=#0000bb]name[/color][color=#007700])){ return [/color][color=#0000bb]i[/color][color=#007700]; } } return -[/color][color=#0000bb]1[/color][color=#007700]; }}[/color] 
    </blockquote></div>
    </div>
    </div>

    câu 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 [/color][color=#007700]array; [/color][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].*; public class [/color][color=#0000bb]bai2 [/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 n[/color][color=#007700]; [/color][color=#0000bb]int arrint[/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]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhap n: "[/color][color=#007700]); [/color][color=#0000bb]n [/color][color=#007700]= [/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]arrint [/color][color=#007700]= new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]n[/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]arrint[/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].print([/color][color=#dd0000]"nhap gia tri thu "[/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]arrint[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]] = [/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextint[/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]"mang vua nhap la: "[/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]arrint[/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].print([/color][color=#0000bb]arrint[/color][color=#007700][[/color][color=#0000bb]i[/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]""[/color][color=#007700]); [/color][color=#0000bb]int temp[/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]arrint[/color][color=#007700].[/color][color=#0000bb]length[/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]i[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ if([/color][color=#0000bb]arrint[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]<[/color][color=#0000bb]arrint[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]){ [/color][color=#0000bb]temp [/color][color=#007700]= [/color][color=#0000bb]arrint[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]; [/color][color=#0000bb]arrint[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]] = [/color][color=#0000bb]arrint[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]; [/color][color=#0000bb]arrint[/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]"mang sau khi sap xep la: "[/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]arrint[/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].print([/color][color=#0000bb]arrint[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]+[/color][color=#dd0000]" "[/color][color=#007700]); } }}[/color] 
    </blockquote></div>
    </div>
    </div>
    câu 3:
    mình chưa làm được
    a ơi a giải thích cụ thể bài 1 cho e với đk không từ chỗ class sinhvien
    xuống dưới ấy

Trang 6 của 9 Đầu tiênĐầu tiên ... 45678 ... CuốiCuối

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •