Trang 7 của 9 Đầu tiênĐầu tiên ... 56789 CuốiCuối
Kết quả 61 đến 70 của 85
  1. #61
    Ngày tham gia
    Jul 2015
    Bài viết
    54
    Mã nguồn PHP:
    [color=#000000]
    [/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] 
    cho mình hỏi if(ten.quals(arrstring)); này nghĩa là gì mình mới học mong các bạn chỉ bảo.

  2. #62
    Ngày tham gia
    Apr 2014
    Bài viết
    0
    Trích dẫn Gửi bởi xuanthu
    bác nào dảnh xem giúp e nhé!!!
    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]
    [/color][color=#ff8000]/** to change this template, choose tools | templates* and open the template in the editor.*/[/color][color=#0000bb]package arrdemo[/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]//số sinh viên nhập từ bàn phím. khai báo 1 mảng gồm danh sách họ tên sinh viên.//tên từng sinh viên nhập từ bàn phím. //sau khi nhập xong, chương trình hỏi nhập tên sinh viên muốn tìm kiếm.//tìm và in ra kết quả là có trong danh sách hay không.[/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 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]int i[/color][color=#007700]; [/color][color=#0000bb]boolean kq[/color][color=#007700]=[/color][color=#0000bb]false[/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ố sinh viên : "[/color][color=#007700]); [/color][color=#0000bb]int 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]string a [/color][color=#007700][] = new [/color][color=#0000bb]string [/color][color=#007700][[/color][color=#0000bb]n[/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]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]"nhập sinh viên thứ : "[/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]in[/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]string b [/color][color=#007700]= [/color][color=#0000bb]in[/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]n[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]++) { if([/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]equals[/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]"có trong danh sách"[/color][color=#007700]); [/color][color=#0000bb]kq[/color][color=#007700]=[/color][color=#0000bb]false[/color][color=#007700]; } }if([/color][color=#0000bb]kq[/color][color=#007700]==[/color][color=#0000bb]false[/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]"khong có trong danh sách"[/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]
    [/color][color=#ff8000]/** to change this template, choose tools | templates* and open the template in the editor.*/[/color][color=#0000bb]package arrdemo[/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]//sắp xếp 1 dãy n số nguyên nhập vào từ bàn phím theo thứ tự tăng dần![/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]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]int tmp[/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ố phần tử của dãy : "[/color][color=#007700]); [/color][color=#0000bb]int n[/color][color=#007700]=[/color][color=#0000bb]in[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]int [/color][color=#007700][][/color][color=#0000bb]a [/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]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]"nhập phần từ thứ "[/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]in[/color][color=#007700].[/color][color=#0000bb]nextint[/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]i[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ if([/color][color=#0000bb]a[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]<[/color][color=#0000bb]a[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]){ [/color][color=#0000bb]tmp [/color][color=#007700]= [/color][color=#0000bb]a[/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]a[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]; [/color][color=#0000bb]a[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]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]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]" " [/color][color=#007700]+ [/color][color=#0000bb]a[/color][color=#007700][[/color][color=#0000bb]i[/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]
    [/color][color=#ff8000]/** to change this template, choose tools | templates* and open the template in the editor.*/ [/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 mrkhoai*/[/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]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]" nhập số hàng : "[/color][color=#007700]); [/color][color=#0000bb]int h[/color][color=#007700]=[/color][color=#0000bb]in[/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]"nhập số cột : "[/color][color=#007700]); [/color][color=#0000bb]int c[/color][color=#007700]=[/color][color=#0000bb]in[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]int a1[/color][color=#007700][][]= new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]h[/color][color=#007700]][[/color][color=#0000bb]c[/color][color=#007700]]; [/color][color=#0000bb]int a2[/color][color=#007700][][]= new [/color][color=#0000bb]int [/color][color=#007700][[/color][color=#0000bb]h[/color][color=#007700]][[/color][color=#0000bb]c[/color][color=#007700]]; [/color][color=#0000bb]int a3[/color][color=#007700][][]=new [/color][color=#0000bb]int [/color][color=#007700][[/color][color=#0000bb]h[/color][color=#007700]][[/color][color=#0000bb]c[/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 ma trận a1"[/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]h[/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]c[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhập a1["[/color][color=#007700]+[/color][color=#0000bb]i[/color][color=#007700]+[/color][color=#dd0000]"]"[/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]a1[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]in[/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]"nhập ma trận a2"[/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]h[/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]c[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhập a1["[/color][color=#007700]+[/color][color=#0000bb]i[/color][color=#007700]+[/color][color=#dd0000]"]"[/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]a2[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]in[/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 trận a1 là : "[/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]h[/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]c[/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]a1[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]); } [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#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]"ma trận a2 là : "[/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]h[/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]c[/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]a2[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]); } [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#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]"tổng 2 ma trận là :"[/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]h[/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]c[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ [/color][color=#0000bb]a3[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]a1[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]+[/color][color=#0000bb]a2[/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]a3[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]); }[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]""[/color][color=#007700]); } } } [/color] 
    </blockquote></div>
    </div>
    </div>
    bài 1 bạn nên sửa
    for( i=0;i< n;i++) {
    if(b.equals(a)){
    kq=false;
    system.out.println("có trong danh sách");
    }else {
    system.out.println("khong có trong danh sách");
    break;
    }
    nó sẽ hiển thị đúng đó.
    và bạn tạo
    scanner in1=new scanner(system.in); cho a
    scanner in=new scanner(system.in); cho b
    riêng biệt thì nó sẽ không tự nhảy xuống hàng nữa.

  3. #63
    Ngày tham gia
    Apr 2015
    Bài viết
    14
    Trích dẫn Gửi bởi xuanthu
    bác nào dảnh xem giúp e nhé!!!
    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]
    [/color][color=#ff8000]/** to change this template, choose tools | templates* and open the template in the editor.*/[/color][color=#0000bb]package arrdemo[/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]//số sinh viên nhập từ bàn phím. khai báo 1 mảng gồm danh sách họ tên sinh viên.//tên từng sinh viên nhập từ bàn phím. //sau khi nhập xong, chương trình hỏi nhập tên sinh viên muốn tìm kiếm.//tìm và in ra kết quả là có trong danh sách hay không.[/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 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]int i[/color][color=#007700]; [/color][color=#0000bb]boolean kq[/color][color=#007700]=[/color][color=#0000bb]false[/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ố sinh viên : "[/color][color=#007700]); [/color][color=#0000bb]int 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]string a [/color][color=#007700][] = new [/color][color=#0000bb]string [/color][color=#007700][[/color][color=#0000bb]n[/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]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]"nhập sinh viên thứ : "[/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]in[/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]string b [/color][color=#007700]= [/color][color=#0000bb]in[/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]n[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]++) { if([/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]equals[/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]"có trong danh sách"[/color][color=#007700]); [/color][color=#0000bb]kq[/color][color=#007700]=[/color][color=#0000bb]false[/color][color=#007700]; } }if([/color][color=#0000bb]kq[/color][color=#007700]==[/color][color=#0000bb]false[/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]"khong có trong danh sách"[/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]
    [/color][color=#ff8000]/** to change this template, choose tools | templates* and open the template in the editor.*/[/color][color=#0000bb]package arrdemo[/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]//sắp xếp 1 dãy n số nguyên nhập vào từ bàn phím theo thứ tự tăng dần![/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]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]int tmp[/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ố phần tử của dãy : "[/color][color=#007700]); [/color][color=#0000bb]int n[/color][color=#007700]=[/color][color=#0000bb]in[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]int [/color][color=#007700][][/color][color=#0000bb]a [/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]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]"nhập phần từ thứ "[/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]in[/color][color=#007700].[/color][color=#0000bb]nextint[/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]i[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ if([/color][color=#0000bb]a[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]<[/color][color=#0000bb]a[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]){ [/color][color=#0000bb]tmp [/color][color=#007700]= [/color][color=#0000bb]a[/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]a[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]; [/color][color=#0000bb]a[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]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]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]" " [/color][color=#007700]+ [/color][color=#0000bb]a[/color][color=#007700][[/color][color=#0000bb]i[/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]
    [/color][color=#ff8000]/** to change this template, choose tools | templates* and open the template in the editor.*/ [/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 mrkhoai*/[/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]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]" nhập số hàng : "[/color][color=#007700]); [/color][color=#0000bb]int h[/color][color=#007700]=[/color][color=#0000bb]in[/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]"nhập số cột : "[/color][color=#007700]); [/color][color=#0000bb]int c[/color][color=#007700]=[/color][color=#0000bb]in[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]int a1[/color][color=#007700][][]= new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]h[/color][color=#007700]][[/color][color=#0000bb]c[/color][color=#007700]]; [/color][color=#0000bb]int a2[/color][color=#007700][][]= new [/color][color=#0000bb]int [/color][color=#007700][[/color][color=#0000bb]h[/color][color=#007700]][[/color][color=#0000bb]c[/color][color=#007700]]; [/color][color=#0000bb]int a3[/color][color=#007700][][]=new [/color][color=#0000bb]int [/color][color=#007700][[/color][color=#0000bb]h[/color][color=#007700]][[/color][color=#0000bb]c[/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 ma trận a1"[/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]h[/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]c[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhập a1["[/color][color=#007700]+[/color][color=#0000bb]i[/color][color=#007700]+[/color][color=#dd0000]"]"[/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]a1[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]in[/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]"nhập ma trận a2"[/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]h[/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]c[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhập a1["[/color][color=#007700]+[/color][color=#0000bb]i[/color][color=#007700]+[/color][color=#dd0000]"]"[/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]a2[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]in[/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 trận a1 là : "[/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]h[/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]c[/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]a1[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]); } [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#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]"ma trận a2 là : "[/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]h[/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]c[/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]a2[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]); } [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#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]"tổng 2 ma trận là :"[/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]h[/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]c[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ [/color][color=#0000bb]a3[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]a1[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]+[/color][color=#0000bb]a2[/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]a3[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]); }[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]""[/color][color=#007700]); } } } [/color] 
    </blockquote></div>
    </div>
    </div>
    bài này dùng được cho các loại ma trận a[][] , ko riêng gì ma trận vuông theo đề bài ^^

  4. #64
    Ngày tham gia
    May 2014
    Bài viết
    0
    từ bài này code khá dài và chấm mất công vị vậy ở mỗi bài bạn có thể cho đáp án ở dưới luôn. để khi mình làm xong tiện so sánh và đối chiếu. mình là người mới bắt đầu tìm hiểu vào lập trình java nên ở nhiều bài thấy các bạn làm có các kiến thức mà ở các bài trước chưa có vì vậy xem đáp án của họ cũng ko hiểu hết dk

  5. #65
    Ngày tham gia
    Mar 2015
    Bài viết
    0
    m.n xem dùm bài này nếu mình muốn tách chổ xuất mảng ra 1 phương thức mới thì làm sao vậy.....
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>bai2 (move your mouse to reveal the content)</noscript>

    bai2 (open)
    bai2 (close)

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

    Mã nguồn PHP:
    [color=#000000]
    package bai2[/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]{[/color][color=#0000bb]int n[/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]);public [/color][color=#0000bb]void nhapn[/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 so nguyen n:"[/color][color=#007700]);[/color][color=#0000bb]n [/color][color=#007700]= [/color][color=#0000bb]s[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700]();}public [/color][color=#0000bb]void nhappt[/color][color=#007700]() {[/color][color=#0000bb]int arrayint[/color][color=#007700][] = new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]n[/color][color=#007700]];[/color][color=#0000bb]int tam[/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]1[/color][color=#007700]));[/color][color=#0000bb]arrayint[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]=[/color][color=#0000bb]s[/color][color=#007700].[/color][color=#0000bb]nextint[/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]++) {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]j[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]++) {if([/color][color=#0000bb]arrayint[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]>[/color][color=#0000bb]arrayint[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]) {[/color][color=#0000bb]tam[/color][color=#007700]=[/color][color=#0000bb]arrayint[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]];[/color][color=#0000bb]arrayint[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]arrayint[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]];[/color][color=#0000bb]arrayint[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]=[/color][color=#0000bb]tam[/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]"ds sau khi sap xep:"[/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]" " [/color][color=#007700]+ [/color][color=#0000bb]arrayint[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]);} }}[/color] 
    Mã nguồn PHP:
    [color=#000000]
    package bai2[/color][color=#007700];public class [/color][color=#0000bb]main [/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]bai2 bai2 [/color][color=#007700]= new [/color][color=#0000bb]bai2[/color][color=#007700]();[/color][color=#0000bb]bai2[/color][color=#007700].[/color][color=#0000bb]nhapn[/color][color=#007700]();[/color][color=#0000bb]bai2[/color][color=#007700].[/color][color=#0000bb]nhappt[/color][color=#007700]();}}[/color] 

  6. #66
    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]
    import java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]scanner[/color][color=#007700];public class [/color][color=#0000bb]arrdemo [/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 stu[/color][color=#007700], [/color][color=#0000bb]findstu[/color][color=#007700]; [/color][color=#0000bb]string [/color][color=#007700][] [/color][color=#0000bb]arrstu [/color][color=#007700]= new [/color][color=#0000bb]string[/color][color=#007700][[/color][color=#0000bb]3[/color][color=#007700]]; [/color][color=#0000bb]scanner nhap [/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]3[/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 tên sinh viên thứ: "[/color][color=#007700]+[/color][color=#0000bb]i[/color][color=#007700]); [/color][color=#0000bb]stu [/color][color=#007700]= [/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); [/color][color=#0000bb]arrstu[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]=[/color][color=#0000bb]stu[/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 sv muôn tìm: "[/color][color=#007700]); [/color][color=#0000bb]findstu [/color][color=#007700]= [/color][color=#0000bb]nhap[/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]"sv :"[/color][color=#007700]+[/color][color=#0000bb]findstu[/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]3[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++) { if([/color][color=#0000bb]findstu[/color][color=#007700].[/color][color=#0000bb]equals[/color][color=#007700]([/color][color=#0000bb]arrstu[/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]"sv có trong ds!"[/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 có sv trong ds!"[/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=#ff8000]//bài 2 [/color][color=#0000bb]int [/color][color=#007700][] [/color][color=#0000bb]arrn [/color][color=#007700]= {[/color][color=#0000bb]2[/color][color=#007700],[/color][color=#0000bb]8[/color][color=#007700],[/color][color=#0000bb]6[/color][color=#007700],[/color][color=#0000bb]1[/color][color=#007700],[/color][color=#0000bb]0[/color][color=#007700],[/color][color=#0000bb]9[/color][color=#007700],[/color][color=#0000bb]4[/color][color=#007700],[/color][color=#0000bb]7[/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]arrn[/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]arrn[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]<[/color][color=#0000bb]arrn[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]) { [/color][color=#0000bb]int tmp [/color][color=#007700]=[/color][color=#0000bb]arrn[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]; [/color][color=#0000bb]arrn[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]] = [/color][color=#0000bb]arrn[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]; [/color][color=#0000bb]arrn[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]] = [/color][color=#0000bb]tmp[/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: "[/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]arrn[/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]arrn[/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]scanner sl [/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 hang:"[/color][color=#007700]); [/color][color=#0000bb]int m [/color][color=#007700]= [/color][color=#0000bb]sl[/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 so cot:"[/color][color=#007700]); [/color][color=#0000bb]int n [/color][color=#007700]= [/color][color=#0000bb]sl[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]int [/color][color=#007700][][] [/color][color=#0000bb]arrma [/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]arrmb [/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]arrmc [/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]"nhap hang 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]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]arrma[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]] = [/color][color=#0000bb]sl[/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 hang 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]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]arrmb[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]] = [/color][color=#0000bb]sl[/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 trận 1 là : "[/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]" "[/color][color=#007700]+[/color][color=#0000bb]arrma[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]); } [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#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]"ma trận 2 là : "[/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]" "[/color][color=#007700]+[/color][color=#0000bb]arrmb[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]); } [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#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]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]arrmc[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]= [/color][color=#0000bb]arrma[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]+[/color][color=#0000bb]arrmb[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]; } } [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"tổng 2 ma trậ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]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]" "[/color][color=#007700]+[/color][color=#0000bb]arrmc[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]); } [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]""[/color][color=#007700]); } } } }[/color] 
    </blockquote></div>
    </div>
    </div>

  7. #67
    Ngày tham gia
    Feb 2015
    Bài viết
    0
    admin oi em nghi la anh nen them nhieu vi du minh hoa hon.....nhieu luc doc cha hieu cai j

  8. #68
    Ngày tham gia
    Mar 2014
    Bài viết
    4
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>bai01 (move your mouse to reveal the content)</noscript>

    bai01 (open)
    bai01 (close)

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


    Mã nguồn PHP:
    [color=#000000]
    package edu[/color][color=#007700].[/color][color=#0000bb]ducky[/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]arraydemo [/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 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]int numberstudents[/color][color=#007700];[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhap so luong sinh vien:"[/color][color=#007700]);[/color][color=#0000bb]numberstudents [/color][color=#007700]= [/color][color=#0000bb]integer[/color][color=#007700].[/color][color=#0000bb]parseint[/color][color=#007700]([/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]());[/color][color=#0000bb]string liststudents[/color][color=#007700][] = new [/color][color=#0000bb]string[/color][color=#007700][[/color][color=#0000bb]numberstudents[/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]liststudents[/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]"ten cua sinh vien thu " [/color][color=#007700]+ [/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#dd0000]":"[/color][color=#007700]);[/color][color=#0000bb]liststudents[/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]string find[/color][color=#007700];[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhap ten sinh vien can tim:"[/color][color=#007700]);[/color][color=#0000bb]find [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]();[/color][color=#0000bb]boolean result [/color][color=#007700]= [/color][color=#0000bb]false[/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]liststudents[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++) {if ([/color][color=#0000bb]find[/color][color=#007700].[/color][color=#0000bb]compareto[/color][color=#007700]([/color][color=#0000bb]liststudents[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]) == [/color][color=#0000bb]0[/color][color=#007700]) {[/color][color=#0000bb]result [/color][color=#007700]= [/color][color=#0000bb]true[/color][color=#007700];}}if ([/color][color=#0000bb]result [/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]"sinh vien co ten " [/color][color=#007700]+ [/color][color=#0000bb]find [/color][color=#007700]+ [/color][color=#dd0000]" da duoc tim thay"[/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 ten " [/color][color=#007700]+ [/color][color=#0000bb]find[/color][color=#007700]);[/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]close[/color][color=#007700]();}}[/color] 
    </blockquote></div>
    </div>
    </div>

    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>bai02 (move your mouse to reveal the content)</noscript>

    bai02 (open)
    bai02 (close)

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


    Mã nguồn PHP:
    [color=#000000]
    package edu[/color][color=#007700].[/color][color=#0000bb]ducky[/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]arrayarrangement [/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 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]int n[/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]in[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700]();[/color][color=#0000bb]int a[/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]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=#dd0000]"nhap so nguyen 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]a[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]] = [/color][color=#0000bb]in[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700]();} [/color][color=#ff8000]//sap xep[/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]a[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]] > [/color][color=#0000bb]a[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]){[/color][color=#0000bb]int temp [/color][color=#007700]= [/color][color=#0000bb]a[/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]a[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]];[/color][color=#0000bb]a[/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]"day so nguyen sau khi duoc sap xep"[/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]a[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]+[/color][color=#dd0000]" "[/color][color=#007700]);[/color][color=#0000bb]in[/color][color=#007700].[/color][color=#0000bb]close[/color][color=#007700]();}}[/color] 
    </blockquote></div>
    </div>
    </div>



    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>bai03 (move your mouse to reveal the content)</noscript>

    bai03 (open)
    bai03 (close)

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


    Mã nguồn PHP:
    [color=#000000]
    package edu[/color][color=#007700].[/color][color=#0000bb]ducky[/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]matriz [/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 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]int n[/color][color=#007700];[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"input number line and column:"[/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]int array1[/color][color=#007700][][] = new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]n[/color][color=#007700]][[/color][color=#0000bb]n[/color][color=#007700]];[/color][color=#0000bb]int array2[/color][color=#007700][][] = new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]n[/color][color=#007700]][[/color][color=#0000bb]n[/color][color=#007700]]; [/color][color=#0000bb]int i[/color][color=#007700], [/color][color=#0000bb]j[/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]n[/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]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]"input array1[" [/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]array1[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]] = [/color][color=#0000bb]in[/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]n[/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]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]"input array2[" [/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]array2[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]] = [/color][color=#0000bb]in[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700]();}[/color][color=#ff8000]//addition array1 and array2[/color][color=#0000bb]int array3[/color][color=#007700][][] = new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]n[/color][color=#007700]][[/color][color=#0000bb]n[/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]n[/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]n[/color][color=#007700]; [/color][color=#0000bb]j[/color][color=#007700]++){[/color][color=#0000bb]array3[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]] = [/color][color=#0000bb]array1[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]] + [/color][color=#0000bb]array2[/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=#0000bb]array3[/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]in[/color][color=#007700].[/color][color=#0000bb]close[/color][color=#007700]();}}[/color] 
    </blockquote></div>
    </div>
    </div>

  9. #69
    Ngày tham gia
    Jun 2014
    Bài viết
    0
    Trích dẫn Gửi bởi xuanthu
    bác nào dảnh xem giúp e nhé!!!
    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]
    [/color][color=#ff8000]/** to change this template, choose tools | templates* and open the template in the editor.*/[/color][color=#0000bb]package arrdemo[/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]//số sinh viên nhập từ bàn phím. khai báo 1 mảng gồm danh sách họ tên sinh viên.//tên từng sinh viên nhập từ bàn phím. //sau khi nhập xong, chương trình hỏi nhập tên sinh viên muốn tìm kiếm.//tìm và in ra kết quả là có trong danh sách hay không.[/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 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]int i[/color][color=#007700]; [/color][color=#0000bb]boolean kq[/color][color=#007700]=[/color][color=#0000bb]false[/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ố sinh viên : "[/color][color=#007700]); [/color][color=#0000bb]int 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]string a [/color][color=#007700][] = new [/color][color=#0000bb]string [/color][color=#007700][[/color][color=#0000bb]n[/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]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]"nhập sinh viên thứ : "[/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]in[/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]string b [/color][color=#007700]= [/color][color=#0000bb]in[/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]n[/color][color=#007700];[/color][color=#0000bb]i[/color][color=#007700]++) { if([/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]equals[/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]"có trong danh sách"[/color][color=#007700]); [/color][color=#0000bb]kq[/color][color=#007700]=[/color][color=#0000bb]false[/color][color=#007700]; } }if([/color][color=#0000bb]kq[/color][color=#007700]==[/color][color=#0000bb]false[/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]"khong có trong danh sách"[/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]
    [/color][color=#ff8000]/** to change this template, choose tools | templates* and open the template in the editor.*/[/color][color=#0000bb]package arrdemo[/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]//sắp xếp 1 dãy n số nguyên nhập vào từ bàn phím theo thứ tự tăng dần![/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]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]int tmp[/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ố phần tử của dãy : "[/color][color=#007700]); [/color][color=#0000bb]int n[/color][color=#007700]=[/color][color=#0000bb]in[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]int [/color][color=#007700][][/color][color=#0000bb]a [/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]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]"nhập phần từ thứ "[/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]in[/color][color=#007700].[/color][color=#0000bb]nextint[/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]i[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ if([/color][color=#0000bb]a[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]<[/color][color=#0000bb]a[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]){ [/color][color=#0000bb]tmp [/color][color=#007700]= [/color][color=#0000bb]a[/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]a[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]; [/color][color=#0000bb]a[/color][color=#007700][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]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]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]" " [/color][color=#007700]+ [/color][color=#0000bb]a[/color][color=#007700][[/color][color=#0000bb]i[/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]
    [/color][color=#ff8000]/** to change this template, choose tools | templates* and open the template in the editor.*/ [/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 mrkhoai*/[/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]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]" nhập số hàng : "[/color][color=#007700]); [/color][color=#0000bb]int h[/color][color=#007700]=[/color][color=#0000bb]in[/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]"nhập số cột : "[/color][color=#007700]); [/color][color=#0000bb]int c[/color][color=#007700]=[/color][color=#0000bb]in[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); [/color][color=#0000bb]int a1[/color][color=#007700][][]= new [/color][color=#0000bb]int[/color][color=#007700][[/color][color=#0000bb]h[/color][color=#007700]][[/color][color=#0000bb]c[/color][color=#007700]]; [/color][color=#0000bb]int a2[/color][color=#007700][][]= new [/color][color=#0000bb]int [/color][color=#007700][[/color][color=#0000bb]h[/color][color=#007700]][[/color][color=#0000bb]c[/color][color=#007700]]; [/color][color=#0000bb]int a3[/color][color=#007700][][]=new [/color][color=#0000bb]int [/color][color=#007700][[/color][color=#0000bb]h[/color][color=#007700]][[/color][color=#0000bb]c[/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 ma trận a1"[/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]h[/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]c[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhập a1["[/color][color=#007700]+[/color][color=#0000bb]i[/color][color=#007700]+[/color][color=#dd0000]"]"[/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]a1[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]in[/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]"nhập ma trận a2"[/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]h[/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]c[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhập a1["[/color][color=#007700]+[/color][color=#0000bb]i[/color][color=#007700]+[/color][color=#dd0000]"]"[/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]a2[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]in[/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 trận a1 là : "[/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]h[/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]c[/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]a1[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]); } [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#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]"ma trận a2 là : "[/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]h[/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]c[/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]a2[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]); } [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#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]"tổng 2 ma trận là :"[/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]h[/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]c[/color][color=#007700];[/color][color=#0000bb]j[/color][color=#007700]++){ [/color][color=#0000bb]a3[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]=[/color][color=#0000bb]a1[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]+[/color][color=#0000bb]a2[/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]a3[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]][[/color][color=#0000bb]j[/color][color=#007700]]); }[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]""[/color][color=#007700]); } } } [/color] 
    </blockquote></div>
    </div>
    </div>
    bài 1 theo mình trong câu lệnh for( i=0;i<n;i++) bạn nên để i>0

  10. #70
    Ngày tham gia
    Apr 2015
    Bài viết
    0
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>code bai 3 chuan nhat! (move your mouse to reveal the content)</noscript>

    code bai 3 chuan nhat! (open)
    code bai 3 chuan nhat! (close)

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

    Mã nguồn PHP:
    [color=#000000]
    [/color
    package java;
    import java.util.scanner;
    public class matrix {
    private int[][] matrix1, matrix2, summatrix; // summatrix de luu tong 2 ma
    // tran
    private int numberrow, numbercolumn;

    public matrix() {
    system.out.println("nhap so hang va so cot cua 2 ma tran : ");
    scanner inp = new scanner(system.in);
    numberrow = inp.nextint(); // nhap so hang
    numbercolumn = inp.nextint(); // nhap so cot
    matrix1 = new int[numberrow][numbercolumn];
    matrix2 = new int[numberrow][numbercolumn];
    }

    public void input(int matrix[][]) {
    scanner inp = new scanner(system.in);
    for (int i = 0; i < numberrow; i++)
    // nhap ma tran dau tien
    for (int j = 0; j < numbercolumn; j++) {
    system.out.print("a[" + i + "][" + j + "] = ");
    matrix[j] = inp.nextint();
    }

    }

    public void show(int matrix[][]) { // dua ma tran ra man hinh
    system.out.println();
    for (int i = 0; i < numberrow; i++) {
    for (int j = 0; j < numbercolumn; j++)

    system.out.print(matrix[j] + " ");
    system.out.print("
    ");
    }
    }

    public void sumoftowmatrix() { // tinh tong 2 ma tran
    summatrix = new int[numberrow][numbercolumn];
    int i = 0, j;
    while(i<numberrow){
    for (j = 0; j<numbercolumn; j++)
    summatrix[j] = matrix1[j] + matrix2[j];
    i++;
    }

    }

    public static void main(string[] args) {
    matrix mt = new matrix();
    system.out.println("nhap cac phan tu cho ma tran thu nhat : ");
    mt.input(mt.matrix1);
    system.out.println("nhap cac phan tu cho ma tran thu hai : ");
    mt.input(mt.matrix2);
    system.out.println("ma tran thu nhat da nhap la : ");
    mt.show(mt.matrix1);
    system.out.println("
    ma tran thu hai da nhap la : ");
    mt.show(mt.matrix2);
    mt.sumoftowmatrix();
    system.out.println("
    tong 2 ma tran la : ");
    mt.show(mt.summatrix);
    }
    }

Trang 7 của 9 Đầu tiênĐầu tiên ... 56789 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
  •