Trang 2 của 4 Đầu tiênĐầu tiên 1234 CuốiCuối
Kết quả 11 đến 20 của 40
  1. #11
    Ngày tham gia
    Apr 2015
    Bài viết
    0
    <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ã:
    public class btbai25b{
        public static void main(string[]args){
            string []arr={"nguyen van h","nguyen tai a","nguyen thi h","le van nguyen","le nguyen a"};
            string tk="a";
            int n=arr.length;
            int i,j;
            int dem=0;
            // in ds sv da dao ten
            system.out.println("ds sv da dao ten:");
            for(i=0;i<n;i++)
            {
                system.out.println(daoten(arr[i]));
            }
            //sap xep
            string []dao=new string[20];
            string tmp;
           
            for(i=0; i<n;i++)
            {
                dao[i]=daoten(arr[i]);
            }
           
           
            for(i=0;i<n-1;i++)
            {
                for(j=i+1;j<n;j++)
                {
                    if(dao[i].comparetoignorecase(dao[j])>0)
                    {
                        tmp=dao[i];
                        dao[i]=dao[j];
                        dao[j]=tmp;
                    }
                }
            }
    //        in ds hs dao nguoc
            system.out.println("ds ten hs duoc sap xep :");
            for(i=0;i<n;i++)
            {
                system.out.println(dao[i]);
            }
           
            // in ds chinh thuc
            string []b=new string[20];
            system.out.println("ds chinh thuc: ");
           
            for(i=0;i<n;i++)
            {
                b[i]=daoten(daoten(dao[i]));
                system.out.println(daoten(daoten(dao[i])));
            }
            // tim kiem hs ten a
            system.out.println("tim kiem hs co ten : "+tk);
            for(i=0;i<n;i++)
            {
                if(b[i].indexof(tk) != -1)
                {
                    system.out.println(b[i]);
                    dem++;
                }
            }
            system.out.println("co "+dem+" hs co ten "+tk);
        }
        public static string daoten(string str)
        {                                     
            string[] temp=str.split(" ");
            str ="";
            str=temp[temp.length-1]+" ";
            for (int i=0;i<temp.length-1;i++)
            {
                str=str + temp[i]+" ";
            }
        //  system.out.println(str);
            return str;
        }
       
    }
    </blockquote></div>
    </div>
    </div>

  2. #12
    Ngày tham gia
    Aug 2014
    Bài viết
    0
    nobihust:
    1/ phần sắp xếp ds hs có chỗ chưa đúng.
    vd với ds (nguyen van a; nguyen tai a;nguyen thi h;le van nguyen; le nguyen a)
    sẽ ko thỏa mãn tên 2 ban a sắp xếp gần nhau.
    2/ phần đảo ngược tên bạn làm rất hay.

  3. #13
    Ngày tham gia
    Jan 2015
    Bài viết
    0
    1 cách sắp xếp tên > mọi người góp ý giúp mình xem nhé
    <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ã:
    public class btbai25c {
        public static void main(string[]args){
            string s0=new string("nnguyen tai an");
            string s1=new string("nnguyen van bcand");
            string s2=new string("nnguyen khac an");
            string s3=new string("nguyen thi llllll");
            string s4=new string("nguyen thi hong hhhh");
            string s5=new string("nguyen thi hong hhhh");
            string s6=new string("nguyen van a");
            string[]a={s0,s1,s4,s2,s3,s5,s6};
            sapxep(a);
        }
        public static string ten(string s)
        {
            string []a=s.trim().split(" ");
            string s1=a[a.length-1];
    //        system.out.println("ten : "+a[a.length-1]);
            return s1;
           
        }
        public static void sapxep(string []a)
        {
            int i,j;
            string tmp;
            for(i=0;i<a.length;i++)
            {
                for(j=i+1;j<a.length;j++)
                {
                    if(ten(a[i]).comparetoignorecase(ten(a[j]))>0)
                    {
                        tmp=a[i];
                        a[i]=a[j];
                        a[j]=tmp;
                    }
                }
            }
            for(i=0;i<a.length;i++)
            {
                system.out.println(a[i]);
            }
        }
    }
    </blockquote></div>
    </div>
    </div>
    thanks

  4. #14
    Ngày tham gia
    Apr 2016
    Bài viết
    0
    <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]
    [/color][color=#ff8000]//tạo 1 mảng các chuỗi là danh sách tên học sinh. nhập vào 1 chuỗi nào đó.//sắp xếp danh sách tên theo thứ tự bảng chữ cái a, b, c.....//tìm kiếm tất cả các tên học sinh giống tuyệt đối hoặc gần giống với từ khóa tìm kiếm đều được hiện ra.//ví dụ nhập từ khóa tìm kiếm: "hoang" thì sẽ hiện ra tất cả các tên sau (nếu như chúng có trong danh sách)://hoang thi yen, nguyen hoang hiep, vu van hoang, hoang, hoang, hoang van tien, ...//(kết quả tìm kiếm không phân biệt chữ hoa và chữ thường!)[/color][color=#0000bb]package bai25[/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]bai25 [/color][color=#007700]{private [/color][color=#0000bb]string name[/color][color=#007700][],[/color][color=#0000bb]dao[/color][color=#007700],[/color][color=#0000bb]tg[/color][color=#007700],[/color][color=#0000bb]t[/color][color=#007700],[/color][color=#0000bb]str1[/color][color=#007700];private [/color][color=#0000bb]int n[/color][color=#007700]; public [/color][color=#0000bb]void nhap[/color][color=#007700](){ [/color][color=#0000bb]scanner in [/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]"số sinh viên cần nhập: "[/color][color=#007700]); [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]n [/color][color=#007700]= [/color][color=#0000bb]in[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]in[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); [/color][color=#0000bb]name [/color][color=#007700]= new [/color][color=#0000bb]string[/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]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]"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]" là: "[/color][color=#007700]); [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]name[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]] = [/color][color=#0000bb]in[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); }} public [/color][color=#0000bb]string ten[/color][color=#007700]([/color][color=#0000bb]string str[/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]string [/color][color=#007700][] [/color][color=#0000bb]name [/color][color=#007700]= [/color][color=#0000bb]str[/color][color=#007700].[/color][color=#0000bb]split[/color][color=#007700]([/color][color=#dd0000]" "[/color][color=#007700]); [/color][color=#0000bb]str1 [/color][color=#007700]= [/color][color=#0000bb]name[/color][color=#007700][[/color][color=#0000bb]name[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]-[/color][color=#0000bb]1[/color][color=#007700]]; } return [/color][color=#0000bb]str1[/color][color=#007700];} public [/color][color=#0000bb]void sort[/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]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]ten[/color][color=#007700]([/color][color=#0000bb]name[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]).[/color][color=#0000bb]comparetoignorecase[/color][color=#007700]([/color][color=#0000bb]ten[/color][color=#007700]([/color][color=#0000bb]name[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]))>[/color][color=#0000bb]0[/color][color=#007700]){ [/color][color=#0000bb]tg [/color][color=#007700]= [/color][color=#0000bb]name[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]; [/color][color=#0000bb]name[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]=[/color][color=#0000bb]name[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]; [/color][color=#0000bb]name[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]tg[/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]name[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"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]" là: "[/color][color=#007700]+[/color][color=#0000bb]name[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]); }}public [/color][color=#0000bb]void search[/color][color=#007700](){ [/color][color=#0000bb]scanner in1 [/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]"từ khóa tên sinh viên cần tìm: "[/color][color=#007700]); [/color][color=#0000bb]t [/color][color=#007700]= [/color][color=#0000bb]in1[/color][color=#007700].[/color][color=#0000bb]nextline[/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]tg [/color][color=#007700]= [/color][color=#0000bb]name[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]tolowercase[/color][color=#007700](); if([/color][color=#0000bb]name[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]indexof[/color][color=#007700]([/color][color=#0000bb]t[/color][color=#007700]) != -[/color][color=#0000bb]1[/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]"có những sinh viên: "[/color][color=#007700]+[/color][color=#0000bb]name[/color][color=#007700][[/color][color=#0000bb]i[/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]bai25 a [/color][color=#007700]= new [/color][color=#0000bb]bai25[/color][color=#007700](); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]nhap[/color][color=#007700](); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]sort[/color][color=#007700](); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]search[/color][color=#007700](); }}[/color] 
    </blockquote></div>
    </div>
    </div>

  5. #15
    Ngày tham gia
    Apr 2016
    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];class [/color][color=#0000bb]sinhvien[/color][color=#007700]{ private [/color][color=#0000bb]string name[/color][color=#007700]; [/color][color=#0000bb]int n[/color][color=#007700]; [/color][color=#0000bb]sinhvien[/color][color=#007700][][/color][color=#0000bb]s[/color][color=#007700]; public [/color][color=#0000bb]sinhvien[/color][color=#007700](){} public [/color][color=#0000bb]sinhvien[/color][color=#007700]([/color][color=#0000bb]int n[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]n[/color][color=#007700]=[/color][color=#0000bb]n[/color][color=#007700]; [/color][color=#0000bb]s[/color][color=#007700]=new [/color][color=#0000bb]sinhvien[/color][color=#007700][[/color][color=#0000bb]n[/color][color=#007700]]; } public [/color][color=#0000bb]void nhap[/color][color=#007700]() { [/color][color=#0000bb]scanner sc[/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]); 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]length[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]++) { [/color][color=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]=new [/color][color=#0000bb]sinhvien[/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 thong tin cho sinh vien thu "[/color][color=#007700]+([/color][color=#0000bb]i[/color][color=#007700]+[/color][color=#0000bb]1[/color][color=#007700])); [/color][color=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]name[/color][color=#007700]=[/color][color=#0000bb]sc[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); } } public [/color][color=#0000bb]void chuanhoa[/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]length[/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]name[/color][color=#007700]=[/color][color=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]name[/color][color=#007700].[/color][color=#0000bb]trim[/color][color=#007700](); do{ [/color][color=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]name [/color][color=#007700]= [/color][color=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]name[/color][color=#007700].[/color][color=#0000bb]replace[/color][color=#007700]([/color][color=#dd0000]" "[/color][color=#007700], [/color][color=#dd0000]" "[/color][color=#007700]); }while([/color][color=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]name[/color][color=#007700].[/color][color=#0000bb]indexof[/color][color=#007700]([/color][color=#dd0000]" "[/color][color=#007700])!=-[/color][color=#0000bb]1[/color][color=#007700]); } } public [/color][color=#0000bb]string get_name[/color][color=#007700]([/color][color=#0000bb]sinhvien s[/color][color=#007700]) { [/color][color=#0000bb]string arrname[/color][color=#007700][]=[/color][color=#0000bb]s[/color][color=#007700].[/color][color=#0000bb]name[/color][color=#007700].[/color][color=#0000bb]split[/color][color=#007700]([/color][color=#dd0000]" "[/color][color=#007700]); return [/color][color=#0000bb]arrname[/color][color=#007700][[/color][color=#0000bb]arrname[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]-[/color][color=#0000bb]1[/color][color=#007700]]; } public [/color][color=#0000bb]void sort[/color][color=#007700]() { [/color][color=#0000bb]string y[/color][color=#007700], [/color][color=#0000bb]z[/color][color=#007700]; [/color][color=#0000bb]sinhvien x[/color][color=#007700]; for([/color][color=#0000bb]int i[/color][color=#007700]=[/color][color=#0000bb]1[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]<[/color][color=#0000bb]s[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]-[/color][color=#0000bb]1[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]++) { for([/color][color=#0000bb]int j[/color][color=#007700]=[/color][color=#0000bb]s[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]-[/color][color=#0000bb]1[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]>=[/color][color=#0000bb]i[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]--) { [/color][color=#0000bb]y[/color][color=#007700]=[/color][color=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]-[/color][color=#0000bb]1[/color][color=#007700]].[/color][color=#0000bb]get_name[/color][color=#007700]([/color][color=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]-[/color][color=#0000bb]1[/color][color=#007700]]); [/color][color=#0000bb]z[/color][color=#007700]=[/color][color=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]].[/color][color=#0000bb]get_name[/color][color=#007700]([/color][color=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]); if([/color][color=#0000bb]y[/color][color=#007700].[/color][color=#0000bb]compareto[/color][color=#007700]([/color][color=#0000bb]z[/color][color=#007700])>[/color][color=#0000bb]0[/color][color=#007700]) { [/color][color=#0000bb]x[/color][color=#007700]=[/color][color=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]-[/color][color=#0000bb]1[/color][color=#007700]]; [/color][color=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]-[/color][color=#0000bb]1[/color][color=#007700]]=[/color][color=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]; [/color][color=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]x[/color][color=#007700]; } } } } public [/color][color=#0000bb]void xuat[/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]length[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]++) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]name[/color][color=#007700]); } } public [/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]tukhoa[/color][color=#007700]([/color][color=#0000bb]string x[/color][color=#007700]) { [/color][color=#0000bb]string[/color][color=#007700][][/color][color=#0000bb]arrname[/color][color=#007700]=[/color][color=#0000bb]x[/color][color=#007700].[/color][color=#0000bb]split[/color][color=#007700]([/color][color=#dd0000]" "[/color][color=#007700]); return [/color][color=#0000bb]arrname[/color][color=#007700]; } public [/color][color=#0000bb]void find[/color][color=#007700]([/color][color=#0000bb]string x[/color][color=#007700]) { [/color][color=#0000bb]string[/color][color=#007700][][/color][color=#0000bb]arrname[/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]length[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]++) { [/color][color=#0000bb]arrname[/color][color=#007700]=[/color][color=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]tukhoa[/color][color=#007700]([/color][color=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]name[/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]arrname[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++) { if([/color][color=#0000bb]arrname[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]].[/color][color=#0000bb]comparetoignorecase[/color][color=#007700]([/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=#0000bb]s[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]name[/color][color=#007700]); break; } } } }}public class [/color][color=#0000bb]onstring [/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 s[/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 n[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700]; try{ [/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 luong sinh vien: "[/color][color=#007700]); [/color][color=#0000bb]n[/color][color=#007700]=[/color][color=#0000bb]s[/color][color=#007700].[/color][color=#0000bb]nextint[/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]"errror "[/color][color=#007700]+[/color][color=#0000bb]e[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].exit([/color][color=#0000bb]0[/color][color=#007700]); } [/color][color=#0000bb]sinhvien sv[/color][color=#007700]=new [/color][color=#0000bb]sinhvien[/color][color=#007700]([/color][color=#0000bb]n[/color][color=#007700]); [/color][color=#0000bb]sv[/color][color=#007700].[/color][color=#0000bb]nhap[/color][color=#007700](); [/color][color=#0000bb]sv[/color][color=#007700].[/color][color=#0000bb]chuanhoa[/color][color=#007700](); [/color][color=#0000bb]sv[/color][color=#007700].[/color][color=#0000bb]sort[/color][color=#007700](); [/color][color=#0000bb]sv[/color][color=#007700].[/color][color=#0000bb]xuat[/color][color=#007700](); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhap tu khoa can tim: "[/color][color=#007700]); [/color][color=#0000bb]s[/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]string x[/color][color=#007700]=[/color][color=#0000bb]s[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); [/color][color=#0000bb]sv[/color][color=#007700].[/color][color=#0000bb]find[/color][color=#007700]([/color][color=#0000bb]x[/color][color=#007700]); }}[/color] 

  6. #16
    Ngày tham gia
    Apr 2015
    Bài viết
    0
    đây là bài của mình, mình ko biết cách sắp xếp theo tên, mình đọc các bạn làm mình cũng ko hiểu lắm nên chỉ làm đc thế này thôi: :d
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>

    show spoiler
    hide spoiler

    </div>
    <div class="quotecontent">
    <div class="bbcm_spoiler_noscript"><blockquote>


    Mã nguồn PHP:
    [color=#000000]
    package com[/color][color=#007700].[/color][color=#0000bb]hanhnv[/color][color=#007700].[/color][color=#0000bb]bai25[/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]bai25 [/color][color=#007700]{ private [/color][color=#0000bb]int number[/color][color=#007700]; private [/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]staff[/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]bai25 bai25 [/color][color=#007700]= new [/color][color=#0000bb]bai25[/color][color=#007700](); [/color][color=#0000bb]bai25[/color][color=#007700].[/color][color=#0000bb]inputdata[/color][color=#007700](); [/color][color=#0000bb]bai25[/color][color=#007700].[/color][color=#0000bb]sortdata[/color][color=#007700](); [/color][color=#0000bb]bai25[/color][color=#007700].[/color][color=#0000bb]showdata[/color][color=#007700](); [/color][color=#0000bb]bai25[/color][color=#007700].[/color][color=#0000bb]searchdata[/color][color=#007700](); } public [/color][color=#0000bb]void inputdata[/color][color=#007700]() { [/color][color=#0000bb]scanner s [/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]"enter number of staff in your department:"[/color][color=#007700]); [/color][color=#0000bb]number [/color][color=#007700]= [/color][color=#0000bb]s[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]staff [/color][color=#007700]= new [/color][color=#0000bb]string[/color][color=#007700][[/color][color=#0000bb]number[/color][color=#007700]]; [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"enter staff names in your department:"[/color][color=#007700]); [/color][color=#0000bb]s[/color][color=#007700].[/color][color=#0000bb]nextline[/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]staff[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"enter staff number " [/color][color=#007700]+ ([/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700])); [/color][color=#0000bb]staff[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]] = [/color][color=#0000bb]s[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); } } public [/color][color=#0000bb]void showdata[/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]"the list you had entered:"[/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]staff[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]staff[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]); } } public [/color][color=#0000bb]void sortdata[/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]staff[/color][color=#007700].[/color][color=#0000bb]length [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++) { for ([/color][color=#0000bb]int j [/color][color=#007700]= [/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700]; [/color][color=#0000bb]j [/color][color=#007700]< [/color][color=#0000bb]staff[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]; [/color][color=#0000bb]j[/color][color=#007700]++) { if ([/color][color=#0000bb]staff[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]comparetoignorecase[/color][color=#007700]([/color][color=#0000bb]staff[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]) > [/color][color=#0000bb]0[/color][color=#007700]) { [/color][color=#0000bb]string temp [/color][color=#007700]= [/color][color=#0000bb]staff[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]; [/color][color=#0000bb]staff[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]] = [/color][color=#0000bb]staff[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]; [/color][color=#0000bb]staff[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]] = [/color][color=#0000bb]temp[/color][color=#007700]; } } } } public [/color][color=#0000bb]void searchdata[/color][color=#007700]() { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"enter name you want to search:"[/color][color=#007700]); [/color][color=#0000bb]scanner s [/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]string findname [/color][color=#007700]= [/color][color=#0000bb]s[/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]"and here name you want to search:"[/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]staff[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++) { if ([/color][color=#0000bb]staff[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]tolowercase[/color][color=#007700]().[/color][color=#0000bb]indexof[/color][color=#007700]([/color][color=#0000bb]findname[/color][color=#007700].[/color][color=#0000bb]tolowercase[/color][color=#007700]()) != -[/color][color=#0000bb]1[/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]staff[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]); } } }}[/color] 
    </blockquote></div>
    </div>
    </div>

  7. #17
    Ngày tham gia
    Mar 2014
    Bài viết
    0
    có 1 chuỗi "123456789" lam sao để sắp xếp ngược lại, và in ra kết quả đó được ạ. cảm ơn các pro nhiều.

  8. #18
    Ngày tham gia
    Apr 2015
    Bài viết
    0
    Trích dẫn Gửi bởi phamtuan6996
    có 1 chuỗi "123456789" lam sao để sắp xếp ngược lại, và in ra kết quả đó được ạ. cảm ơn các pro nhiều.
    đây bạn ơi:


    Mã nguồn PHP:
    [color=#000000]
    stringbuffer a [/color][color=#007700]= new [/color][color=#0000bb]stringbuffer[/color][color=#007700]([/color][color=#dd0000]"123456789"[/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]a[/color][color=#007700].[/color][color=#0000bb]reverse[/color][color=#007700]());[/color] 

  9. #19
    Ngày tham gia
    Apr 2015
    Bài viết
    0
    Trích dẫn Gửi bởi nguyentaihanh86
    nobihust:
    1/ phần sắp xếp ds hs có chỗ chưa đúng.
    vd với ds (nguyen van a; nguyen tai a;nguyen thi h;le van nguyen; le nguyen a)
    sẽ ko thỏa mãn tên 2 ban a sắp xếp gần nhau.
    2/ phần đảo ngược tên bạn làm rất hay.
    thế này chắc chuẩn rồi :d


    Mã nguồn PHP:
    [color=#000000]
    package samsung[/color][color=#007700].[/color][color=#0000bb]neo[/color][color=#007700].[/color][color=#0000bb]basic[/color][color=#007700]; [/color][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]scanner[/color][color=#007700]; public class [/color][color=#0000bb]demo [/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]string[/color][color=#007700][] [/color][color=#0000bb]studentlist [/color][color=#007700]= { [/color][color=#dd0000]"hoang thi yen"[/color][color=#007700], [/color][color=#dd0000]"nguyen hoang hiep"[/color][color=#007700], [/color][color=#dd0000]"vu van hoang"[/color][color=#007700], [/color][color=#dd0000]" hoang"[/color][color=#007700], [/color][color=#dd0000]"hoang"[/color][color=#007700], [/color][color=#dd0000]"hoang van tien"[/color][color=#007700], [/color][color=#dd0000]"phan tu quoc thang"[/color][color=#007700], [/color][color=#dd0000]"nguyen van a"[/color][color=#007700], [/color][color=#dd0000]"nguyen tai a "[/color][color=#007700], [/color][color=#dd0000]"nguyen thi h"[/color][color=#007700], [/color][color=#dd0000]"le van nguyen"[/color][color=#007700], [/color][color=#dd0000]" le nguyen a" [/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 chuoi: "[/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=#ff8000]// searching by string [/color][color=#0000bb]int count [/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]studentlist[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++) { if ([/color][color=#0000bb]studentlist[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]tolowercase[/color][color=#007700]().[/color][color=#0000bb]indexof[/color][color=#007700]([/color][color=#0000bb]name[/color][color=#007700].[/color][color=#0000bb]tolowercase[/color][color=#007700]()) != -[/color][color=#0000bb]1[/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]studentlist[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]); [/color][color=#0000bb]count[/color][color=#007700]++; } } if ([/color][color=#0000bb]count [/color][color=#007700]== [/color][color=#0000bb]0[/color][color=#007700]) { try { throw new [/color][color=#0000bb]myexception[/color][color=#007700](); } catch ([/color][color=#0000bb]myexception e[/color][color=#007700]) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]e[/color][color=#007700]); } } 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]"tim thay " [/color][color=#007700]+ [/color][color=#0000bb]count [/color][color=#007700]+ [/color][color=#dd0000]" sinh vien co chuoi " [/color][color=#007700]+ [/color][color=#0000bb]name[/color][color=#007700]); } [/color][color=#ff8000]// sorting by order [/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]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"before sorting"[/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]studentlist[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++) { [/color][color=#0000bb]studentlist[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]] = [/color][color=#0000bb]studentlist[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]trim[/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]studentlist[/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]""[/color][color=#007700]); [/color][color=#0000bb]boolean swap[/color][color=#007700]; [/color][color=#0000bb]int index1[/color][color=#007700], [/color][color=#0000bb]index2[/color][color=#007700]; [/color][color=#0000bb]string temp1[/color][color=#007700], [/color][color=#0000bb]temp2[/color][color=#007700], [/color][color=#0000bb]temp[/color][color=#007700]; for ([/color][color=#0000bb]int i [/color][color=#007700]= [/color][color=#0000bb]studentlist[/color][color=#007700].[/color][color=#0000bb]length [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700]; [/color][color=#0000bb]i [/color][color=#007700]> [/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]--) { [/color][color=#0000bb]swap [/color][color=#007700]= [/color][color=#0000bb]false[/color][color=#007700]; for ([/color][color=#0000bb]int j [/color][color=#007700]= [/color][color=#0000bb]1[/color][color=#007700]; [/color][color=#0000bb]j [/color][color=#007700]<= [/color][color=#0000bb]i[/color][color=#007700]; [/color][color=#0000bb]j[/color][color=#007700]++) { [/color][color=#0000bb]index1 [/color][color=#007700]= [/color][color=#0000bb]studentlist[/color][color=#007700][[/color][color=#0000bb]j [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700]].[/color][color=#0000bb]lastindexof[/color][color=#007700]([/color][color=#0000bb]32[/color][color=#007700]); if ([/color][color=#0000bb]index1 [/color][color=#007700]== -[/color][color=#0000bb]1[/color][color=#007700]) { [/color][color=#0000bb]temp1 [/color][color=#007700]= [/color][color=#0000bb]studentlist[/color][color=#007700][[/color][color=#0000bb]j [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700]]; } else { [/color][color=#0000bb]temp1 [/color][color=#007700]= [/color][color=#0000bb]studentlist[/color][color=#007700][[/color][color=#0000bb]j [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700]].[/color][color=#0000bb]substring[/color][color=#007700]([/color][color=#0000bb]index1 [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700]) + [/color][color=#0000bb]studentlist[/color][color=#007700][[/color][color=#0000bb]j [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700]].[/color][color=#0000bb]substring[/color][color=#007700]([/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]index1[/color][color=#007700]); } [/color][color=#0000bb]index2 [/color][color=#007700]= [/color][color=#0000bb]studentlist[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]].[/color][color=#0000bb]lastindexof[/color][color=#007700]([/color][color=#0000bb]32[/color][color=#007700]); if ([/color][color=#0000bb]index2 [/color][color=#007700]== -[/color][color=#0000bb]1[/color][color=#007700]) { [/color][color=#0000bb]temp2 [/color][color=#007700]= [/color][color=#0000bb]studentlist[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]; } else { [/color][color=#0000bb]temp2 [/color][color=#007700]= [/color][color=#0000bb]studentlist[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]].[/color][color=#0000bb]substring[/color][color=#007700]([/color][color=#0000bb]index2 [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700]) + [/color][color=#0000bb]studentlist[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]].[/color][color=#0000bb]substring[/color][color=#007700]([/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]index2[/color][color=#007700]); } if ([/color][color=#0000bb]temp1[/color][color=#007700].[/color][color=#0000bb]comparetoignorecase[/color][color=#007700]([/color][color=#0000bb]temp2[/color][color=#007700]) > [/color][color=#0000bb]0[/color][color=#007700]) { [/color][color=#0000bb]temp [/color][color=#007700]= [/color][color=#0000bb]studentlist[/color][color=#007700][[/color][color=#0000bb]j [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700]]; [/color][color=#0000bb]studentlist[/color][color=#007700][[/color][color=#0000bb]j [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700]] = [/color][color=#0000bb]studentlist[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]; [/color][color=#0000bb]studentlist[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]] = [/color][color=#0000bb]temp[/color][color=#007700]; [/color][color=#0000bb]swap [/color][color=#007700]= [/color][color=#0000bb]true[/color][color=#007700]; } } if (![/color][color=#0000bb]swap[/color][color=#007700]) { break; } } [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"after sorting"[/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]studentlist[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]studentlist[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]); } }} class [/color][color=#0000bb]myexception [/color][color=#007700]extends [/color][color=#0000bb]exception [/color][color=#007700]{ public [/color][color=#0000bb]string tostring[/color][color=#007700]() { return [/color][color=#dd0000]"khong tim thay sinh vien nao theo yeu cau!"[/color][color=#007700]; }}[/color] 

  10. #20
    Ngày tham gia
    Apr 2015
    Bài viết
    0
    <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]
    [/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]string [/color][color=#007700][] [/color][color=#0000bb]arrsinhvien [/color][color=#007700]= {[/color][color=#dd0000]"nguyen van hoang"[/color][color=#007700], [/color][color=#dd0000]"chau nguyen hoang"[/color][color=#007700], [/color][color=#dd0000]"hoang nhu lan"[/color][color=#007700], [/color][color=#dd0000]"hoang thuong nguyen"[/color][color=#007700],[/color][color=#dd0000]"hoang"[/color][color=#007700],[/color][color=#dd0000]"hoang"[/color][color=#007700], [/color][color=#dd0000]"vo hoang hiep"[/color][color=#007700],[/color][color=#dd0000]"tiep hoang hoa"[/color][color=#007700],[/color][color=#dd0000]"hoang hoang tham"[/color][color=#007700]}; [/color][color=#0000bb]string hoten[/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 sinh vien muon tim kiem: "[/color][color=#007700]); [/color][color=#0000bb]hoten [/color][color=#007700]= [/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); [/color][color=#0000bb]arrsinhvien [/color][color=#007700]= [/color][color=#0000bb]sapthutu[/color][color=#007700]([/color][color=#0000bb]arrsinhvien[/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]arrsinhvien[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]arrsinhvien[/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]"danh sach sinh vien co ten giong voi: " [/color][color=#007700]+ [/color][color=#0000bb]hoten[/color][color=#007700]); [/color][color=#0000bb]timsv[/color][color=#007700]([/color][color=#0000bb]arrsinhvien[/color][color=#007700], [/color][color=#0000bb]hoten[/color][color=#007700]); } public static [/color][color=#0000bb]void timsv[/color][color=#007700]([/color][color=#0000bb]string [/color][color=#007700][] [/color][color=#0000bb]arrsv[/color][color=#007700], [/color][color=#0000bb]string hoten[/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]arrsv[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++) { if ( ([/color][color=#0000bb]arrsv[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]tolowercase[/color][color=#007700]()).[/color][color=#0000bb]indexof[/color][color=#007700]([/color][color=#0000bb]hoten[/color][color=#007700].[/color][color=#0000bb]tolowercase[/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=#0000bb]arrsv[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]); }}public static [/color][color=#0000bb]string ten[/color][color=#007700]([/color][color=#0000bb]string hoten[/color][color=#007700]){ [/color][color=#0000bb]hoten [/color][color=#007700]= [/color][color=#0000bb]hoten[/color][color=#007700].[/color][color=#0000bb]trim[/color][color=#007700](); [/color][color=#0000bb]int pos [/color][color=#007700]= [/color][color=#0000bb]hoten[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]() -[/color][color=#0000bb]1[/color][color=#007700]; while ( [/color][color=#0000bb]pos [/color][color=#007700]>=[/color][color=#0000bb]0 [/color][color=#007700]&& !([/color][color=#0000bb]hoten[/color][color=#007700].[/color][color=#0000bb]substring[/color][color=#007700]([/color][color=#0000bb]pos[/color][color=#007700], [/color][color=#0000bb]pos [/color][color=#007700]+[/color][color=#0000bb]1[/color][color=#007700]).[/color][color=#0000bb]equals[/color][color=#007700]([/color][color=#dd0000]" "[/color][color=#007700]))) { [/color][color=#0000bb]pos[/color][color=#007700]--; } return [/color][color=#0000bb]hoten[/color][color=#007700].[/color][color=#0000bb]substring[/color][color=#007700]([/color][color=#0000bb]pos[/color][color=#007700]+[/color][color=#0000bb]1[/color][color=#007700]);}public static [/color][color=#0000bb]string [/color][color=#007700][] [/color][color=#0000bb]sapthutu[/color][color=#007700]([/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]arrsv[/color][color=#007700]){ [/color][color=#0000bb]string tmp[/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]arrsv[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]-[/color][color=#0000bb]2[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++) { for ([/color][color=#0000bb]int j [/color][color=#007700]= [/color][color=#0000bb]arrsv[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]-[/color][color=#0000bb]1[/color][color=#007700]; [/color][color=#0000bb]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]--) { if ( [/color][color=#0000bb]ten[/color][color=#007700]([/color][color=#0000bb]arrsv[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]).[/color][color=#0000bb]comparetoignorecase[/color][color=#007700]([/color][color=#0000bb]ten[/color][color=#007700]([/color][color=#0000bb]arrsv[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]-[/color][color=#0000bb]1[/color][color=#007700]])) < [/color][color=#0000bb]0[/color][color=#007700]) { [/color][color=#0000bb]tmp [/color][color=#007700]= [/color][color=#0000bb]arrsv[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]; [/color][color=#0000bb]arrsv[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]] = [/color][color=#0000bb]arrsv[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]-[/color][color=#0000bb]1[/color][color=#007700]]; [/color][color=#0000bb]arrsv[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]-[/color][color=#0000bb]1[/color][color=#007700]] = [/color][color=#0000bb]tmp[/color][color=#007700]; } } } return [/color][color=#0000bb]arrsv[/color][color=#007700];}[/color] 
    </blockquote></div>
    </div>
    </div>

Trang 2 của 4 Đầu tiênĐầu tiên 1234 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
  •