Trang 5 của 13 Đầu tiênĐầu tiên ... 34567 ... CuốiCuối
Kết quả 41 đến 50 của 128
  1. #41
    Ngày tham gia
    Nov 2014
    Bài viết
    0
    hi mọi người, tình hình là có một bài về biểu thức toán học,
    đề: tính tổng từ 1 đến n. và n được nhập từ bàn phím sao cho 3<n<50.
    nhập và tính: ok, còn về điều kiện so sánh < 3 ; > 50, bạn nào chỉ với


    Mã:
    package baitap_36_khtn;
    import java.io.*;
     
    public class tinhtong_1_den_n {
        public static void main (string[] args) throws exception {
            bufferedreader in = new bufferedreader(new inputstreamreader(system.in));
            system.out.print("nhap n (3;50): ");
            int n = integer.parseint(in.readline());
            //-xu ly dieu kien nang cao: n ee (3;50)
            /**@author root
            * neu (n<3)v(n>50) --> nhap lai n?
            * else continue
            * **/
            do {
                system.out.print("nhap lai n (3;50): ");
                n = integer.parseint(in.readline());
            } while ((n>50) || (n<3));
            //-ok hy vong doan tren on?
                int i = 0;
                int sum = 0;
                for(;i<=n;i++){
                    sum += i;
                }
                system.out.println("ket qua bai toan tinh tong tu 1 den n la: "+sum);
        }
    }
    cho hỏi thêm là cái || và | có khác nhau gì không, tại thay vào nó cũng ra như nhau, @@ nhập 3 hoặc 50, lúc nó bắt nhập lại, lúc nó cho ra tổng luôn, haiz :\

  2. #42
    Ngày tham gia
    Sep 2015
    Bài viết
    41
    lengocthanh911: | và || khác nhau như nào:
    ở video cuối trong bài này có nói đấy bạn!
    http://android.vn/threads/bai-5-cau-truc-if-else-bieu-thuc-boolean-va-coding-style-trong-java.25913/
    những bài hỏi đáp ngoài bài tập mình nói trong khóa học, bạn vui lòng vào trong mục này
    http://android.vn/forums/hoi-dap-lap-trinh-java.231/

  3. #43
    Ngày tham gia
    Apr 2014
    Bài viết
    0
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>

    show spoiler
    hide spoiler

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


    Mã nguồn PHP:
    [color=#000000]
    [/color][color=#007700]public static [/color][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]args[/color][color=#007700]) { [/color][color=#ff8000]//bài 1: các biến a, b, c là các số nguyên. gán giá trị cho các biến. //tìm phần nguyên khi chia các số này cho 2, tìm phần dư khi chia các số này cho 3, //in kết quả ra màn hình. tăng giá trị a, b, c mỗi biến lên 1, in giá trị 3 số ra màn hình. [/color][color=#0000bb]int a[/color][color=#007700]=[/color][color=#0000bb]123[/color][color=#007700], [/color][color=#0000bb]b[/color][color=#007700]=[/color][color=#0000bb]12[/color][color=#007700], [/color][color=#0000bb]c[/color][color=#007700]=[/color][color=#0000bb]95[/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]"bài 1 : ba số đã nhập là: " [/color][color=#007700]+ [/color][color=#0000bb]a [/color][color=#007700]+ [/color][color=#dd0000]", "[/color][color=#007700]+[/color][color=#0000bb]b[/color][color=#007700]+[/color][color=#dd0000]", "[/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]"phần nguyên khi chia các số này cho 2 là: "[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700]/[/color][color=#0000bb]2[/color][color=#007700]+[/color][color=#dd0000]", "[/color][color=#007700]+[/color][color=#0000bb]b[/color][color=#007700]/[/color][color=#0000bb]2[/color][color=#007700]+[/color][color=#dd0000]", "[/color][color=#007700]+[/color][color=#0000bb]c[/color][color=#007700]/[/color][color=#0000bb]2[/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]"phần dư khi chia các số này cho 3 là: "[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700]%[/color][color=#0000bb]3[/color][color=#007700]+[/color][color=#dd0000]", "[/color][color=#007700]+[/color][color=#0000bb]b[/color][color=#007700]%[/color][color=#0000bb]3[/color][color=#007700]+[/color][color=#dd0000]", "[/color][color=#007700]+[/color][color=#0000bb]c[/color][color=#007700]%[/color][color=#0000bb]3[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700]++; [/color][color=#0000bb]b[/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]"ba số đã được tăng lên 1 là: "[/color][color=#007700]+ [/color][color=#0000bb]a [/color][color=#007700]+[/color][color=#dd0000]", "[/color][color=#007700]+[/color][color=#0000bb]b[/color][color=#007700]+[/color][color=#dd0000]", "[/color][color=#007700]+[/color][color=#0000bb]c[/color][color=#007700]); [/color][color=#ff8000]//bài 2: giải phương trình 2xt+y = 8z với x, y, z là số thực – được gán giá trị trong chương trình, //t cũng là số thực, là giá trị cần tìm. sau khi tính t in kết quả ra màn hình, //ép kiểu t về số nguyên, in kết quả ép kiểu của x ra màn hình! [/color][color=#0000bb]float x[/color][color=#007700]=[/color][color=#0000bb]3.45f[/color][color=#007700], [/color][color=#0000bb]y[/color][color=#007700]=[/color][color=#0000bb]2.54f[/color][color=#007700], [/color][color=#0000bb]z[/color][color=#007700]=[/color][color=#0000bb]6.8723f[/color][color=#007700], [/color][color=#0000bb]t[/color][color=#007700]; [/color][color=#0000bb]int v[/color][color=#007700]; [/color][color=#0000bb]t[/color][color=#007700]=([/color][color=#0000bb]8[/color][color=#007700]*[/color][color=#0000bb]z[/color][color=#007700]-[/color][color=#0000bb]y[/color][color=#007700])/[/color][color=#0000bb]2[/color][color=#007700]/[/color][color=#0000bb]x[/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]"bài 2 : hệ số x, y, z của phương trình 2xt+y=8z là: "[/color][color=#007700]+[/color][color=#0000bb]x[/color][color=#007700]+[/color][color=#dd0000]", "[/color][color=#007700]+[/color][color=#0000bb]y[/color][color=#007700]+[/color][color=#dd0000]", "[/color][color=#007700]+[/color][color=#0000bb]z[/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]"ẩn t cần tìm là: "[/color][color=#007700]+[/color][color=#0000bb]t[/color][color=#007700]); [/color][color=#0000bb]v [/color][color=#007700]= (int) [/color][color=#0000bb]t[/color][color=#007700]; [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"ẩn t đã ép kiểu nguyên là: "[/color][color=#007700]+[/color][color=#0000bb]v[/color][color=#007700]); [/color][color=#ff8000]//bài 3: cho a, b, c là độ dài 3 cạnh tam giác, a, b, c được gán giá trị trong chương trình. //viết chương trình tính diện tích s của tam giác, in kết quả ra màn hình. //tìm số đo 3 góc của tam giác đó, in kết quả ra màn hình. [/color][color=#0000bb]double a3[/color][color=#007700]=[/color][color=#0000bb]3d[/color][color=#007700], [/color][color=#0000bb]b3[/color][color=#007700]=[/color][color=#0000bb]4d[/color][color=#007700], [/color][color=#0000bb]c3[/color][color=#007700]=[/color][color=#0000bb]5d[/color][color=#007700], [/color][color=#0000bb]p[/color][color=#007700], [/color][color=#0000bb]s[/color][color=#007700], [/color][color=#0000bb]g3[/color][color=#007700]; [/color][color=#0000bb]p [/color][color=#007700]= ( [/color][color=#0000bb]a3 [/color][color=#007700]+ [/color][color=#0000bb]b3 [/color][color=#007700]+ [/color][color=#0000bb]c3 [/color][color=#007700]) / [/color][color=#0000bb]2[/color][color=#007700]; [/color][color=#0000bb]s [/color][color=#007700]= [/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]sqrt[/color][color=#007700]([/color][color=#0000bb]p[/color][color=#007700]*([/color][color=#0000bb]p[/color][color=#007700]-[/color][color=#0000bb]a3[/color][color=#007700])*([/color][color=#0000bb]p[/color][color=#007700]-[/color][color=#0000bb]b3[/color][color=#007700])*([/color][color=#0000bb]p[/color][color=#007700]-[/color][color=#0000bb]c3[/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]"bài 3: độ dài 3 cạnh tam giác là: "[/color][color=#007700]+[/color][color=#0000bb]a3[/color][color=#007700]+[/color][color=#dd0000]", "[/color][color=#007700]+[/color][color=#0000bb]b3[/color][color=#007700]+[/color][color=#dd0000]", "[/color][color=#007700]+[/color][color=#0000bb]c3[/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]"diện tích tam giác là:"[/color][color=#007700]+[/color][color=#0000bb]s[/color][color=#007700]); [/color][color=#0000bb]g3 [/color][color=#007700]= [/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]acos[/color][color=#007700](([/color][color=#0000bb]a3[/color][color=#007700]*[/color][color=#0000bb]a3[/color][color=#007700]+[/color][color=#0000bb]b3[/color][color=#007700]*[/color][color=#0000bb]b3[/color][color=#007700]-[/color][color=#0000bb]c3[/color][color=#007700]*[/color][color=#0000bb]c3[/color][color=#007700])/[/color][color=#0000bb]2[/color][color=#007700]/[/color][color=#0000bb]a3[/color][color=#007700]/[/color][color=#0000bb]b3[/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]"góc đối diện cạnh "[/color][color=#007700]+[/color][color=#0000bb]c3[/color][color=#007700]+[/color][color=#dd0000]"là: "[/color][color=#007700]+[/color][color=#0000bb]g3[/color][color=#007700]*[/color][color=#0000bb]180 [/color][color=#007700]/ [/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]pi [/color][color=#007700]+[/color][color=#dd0000]" độ."[/color][color=#007700]); }} [/color] 
    </blockquote></div>
    </div>
    </div>

  4. #44
    Ngày tham gia
    Jun 2015
    Bài viết
    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></blockquote></div>
    </div>
    </div>bai 1:




    Mã nguồn PHP:
    [color=#000000]
    [/color][color=#007700]public static [/color][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]args[/color][color=#007700]) { [/color][color=#0000bb]int a[/color][color=#007700], [/color][color=#0000bb]b[/color][color=#007700], [/color][color=#0000bb]c[/color][color=#007700], [/color][color=#0000bb]du[/color][color=#007700], [/color][color=#0000bb]nguyen[/color][color=#007700]; [/color][color=#0000bb]a[/color][color=#007700]=[/color][color=#0000bb]10[/color][color=#007700]; [/color][color=#0000bb]b[/color][color=#007700]=[/color][color=#0000bb]17[/color][color=#007700]; [/color][color=#0000bb]c[/color][color=#007700]=[/color][color=#0000bb]6[/color][color=#007700]; [/color][color=#0000bb]du[/color][color=#007700]= ([/color][color=#0000bb]a[/color][color=#007700]%[/color][color=#0000bb]3[/color][color=#007700]) + ([/color][color=#0000bb]b[/color][color=#007700]%[/color][color=#0000bb]3[/color][color=#007700]) + ([/color][color=#0000bb]c[/color][color=#007700]%[/color][color=#0000bb]3[/color][color=#007700]); [/color][color=#0000bb]nguyen[/color][color=#007700]= ([/color][color=#0000bb]a[/color][color=#007700]/[/color][color=#0000bb]2[/color][color=#007700]) + ([/color][color=#0000bb]b[/color][color=#007700]/[/color][color=#0000bb]2[/color][color=#007700]) + ([/color][color=#0000bb]c[/color][color=#007700]/[/color][color=#0000bb]2[/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]"phan du +(a:3)+ (b:3) + (c:3) la : " [/color][color=#007700]+[/color][color=#0000bb]du[/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]"phan nguyen +(a:2)+ (b:2)+ (c:2) la :" [/color][color=#007700]+[/color][color=#0000bb]nguyen[/color][color=#007700]); [/color][color=#0000bb]a[/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]"gia tri cua a tang len 1, gia tri moi la : " [/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700]); [/color][color=#0000bb]b[/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]"gia tri cua b tang len 1, gia tri moi la : " [/color][color=#007700]+[/color][color=#0000bb]b[/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]"gia tri cua c tang len 1, gia tri moi la : " [/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]"với 3 giá trị a, b, c mới trên, tích (a x b x c) = " [/color][color=#007700]+ [/color][color=#0000bb]a [/color][color=#007700]* [/color][color=#0000bb]b [/color][color=#007700]* [/color][color=#0000bb]c[/color][color=#007700]); } } [/color] 

  5. #45
    Ngày tham gia
    Apr 2016
    Bài viết
    0
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>

    show spoiler
    hide spoiler

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


    Mã:
    public static void main(string[] args) {
          //  2ax+b = 8c ;
            float a=2.2f, b=3.2f, c=4.2f;
            if (a!=0) {
            float x;
            x = (8*c-b)/(2*a);
            system.out.println("x can tim la : " + x);
            system.out.println("sau khi ep kieu x la : " +(int)  x);
            } else{
                system.out.println("gia tri a phai # 0");
            }
        }
    }

  6. #46
    Ngày tham gia
    Apr 2016
    Bài viết
    0
    mình nộp bài nè.
    bài 1:


    Mã:
    int a = 17, b=25, c = 41;
    system.out.println("phan nguyen khi chia a cho 2 la " + a/2);
    system.out.println("phan nguyen khi chia b cho 2 la " + b/2);
    system.out.println("phan nguyen khi chia c cho 2 la " + c/2);
    system.out.println("phan du khi chia a cho 3 la " + a%3);
    system.out.println("phan du khi chia b cho 3 la " + b%3);
    system.out.println("phan du khi chia c cho 3 la " + c%3);
         
    system.out.println("gia tri cua a,b,c sau khi tang len 1 la " + ++a +" "+ ++b +" "+ ++c
    );
    bài 2:


    Mã:
    float a=2f, b = 3f, c= 4f,x;
    x=(8*c - b)/(2*a);
    system.out.println("gia tri cua x la " + (int)x);
    bài 3:


    Mã:
    float ab= 5f, ac= 6f, bc= 7f;
           
            float cosa, cosb, cosc;
         
            float p;
            p = (float)((ab+ac+bc)/2);
            system.out.println("dien tich tam giac la " + math.sqrt(p*(p-ab)*(p-ac)*(p-bc)));
         
            cosa = (float)((math.pow(ab, 2) + math.pow(ac,2)- math.pow(bc, 2))/(2*ab*ac));
            cosc = (float)((math.pow(ac, 2) + math.pow(bc,2)- math.pow(ab, 2))/(2*ac*bc));
            cosb = (float)((math.pow(bc, 2) + math.pow(ab,2)- math.pow(ac, 2))/(2*ab*bc));
            system.out.println("so do goc a la " + math.todegrees(math.acos(cosa)));
            system.out.println("so do goc b la " + math.todegrees(math.acos(cosb)));
            system.out.println("so do goc c la " + math.todegrees(math.acos(cosc)));

  7. #47
    Ngày tham gia
    Nov 2014
    Bài viết
    0
    bài 1:
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>

    show spoiler
    hide spoiler

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


    Mã nguồn PHP:
    [color=#000000]
    [/color][color=#007700]public static [/color][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]args[/color][color=#007700]) { [/color][color=#0000bb]int a[/color][color=#007700]=[/color][color=#0000bb]24[/color][color=#007700],[/color][color=#0000bb]b[/color][color=#007700]=[/color][color=#0000bb]67[/color][color=#007700],[/color][color=#0000bb]c[/color][color=#007700]=[/color][color=#0000bb]35[/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]"phan nguyen khi chia so a cho 2 = "[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700]/[/color][color=#0000bb]2[/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]"phan nguyen khi chia so b cho 2 = "[/color][color=#007700]+[/color][color=#0000bb]b[/color][color=#007700]/[/color][color=#0000bb]2[/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]"phan nguyen khi chia so c cho 2 = "[/color][color=#007700]+[/color][color=#0000bb]c[/color][color=#007700]/[/color][color=#0000bb]2[/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]"phan du khi chia so a cho 3 = "[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700]%[/color][color=#0000bb]3[/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]"phan du khi chia so b cho 3 = "[/color][color=#007700]+[/color][color=#0000bb]b[/color][color=#007700]%[/color][color=#0000bb]3[/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]"phan du khi chia so c cho 3 = "[/color][color=#007700]+[/color][color=#0000bb]c[/color][color=#007700]%[/color][color=#0000bb]3[/color][color=#007700]); [/color][color=#0000bb]a[/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]"gia tri a khi tang len 1 = "[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700]); [/color][color=#0000bb]b[/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]"gia tri b khi tang len 1 = "[/color][color=#007700]+[/color][color=#0000bb]b[/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]"gia tri c khi tang len 1 = "[/color][color=#007700]+[/color][color=#0000bb]c[/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ã:
     public static void main(string[] args) {
        float a=3.2f,b=2.3f,c=5.6f;
        float x;
        int y;
        x = (8*c-b)/(2*a);
        system.out.println("gia tri x can tim = "+x);
        y = (int) x;
        system.out.println("gia tri x sau khi ep ve kieu so nguyen = "+y);
               
        }
    </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=#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]float a [/color][color=#007700]= [/color][color=#0000bb]3.2f[/color][color=#007700],[/color][color=#0000bb]b [/color][color=#007700]= [/color][color=#0000bb]4.5f[/color][color=#007700],[/color][color=#0000bb]c [/color][color=#007700]= [/color][color=#0000bb]5.4f[/color][color=#007700]; [/color][color=#0000bb]float p[/color][color=#007700],[/color][color=#0000bb]s[/color][color=#007700]; [/color][color=#0000bb]float sina[/color][color=#007700],[/color][color=#0000bb]sinb[/color][color=#007700],[/color][color=#0000bb]sinc[/color][color=#007700]; [/color][color=#0000bb]p [/color][color=#007700]= (float)([/color][color=#0000bb]a[/color][color=#007700]+[/color][color=#0000bb]b[/color][color=#007700]+[/color][color=#0000bb]c[/color][color=#007700])/[/color][color=#0000bb]2[/color][color=#007700]; [/color][color=#0000bb]s [/color][color=#007700]=(float) [/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]sqrt[/color][color=#007700]([/color][color=#0000bb]p[/color][color=#007700]*([/color][color=#0000bb]p[/color][color=#007700]-[/color][color=#0000bb]a[/color][color=#007700])*([/color][color=#0000bb]p[/color][color=#007700]-[/color][color=#0000bb]b[/color][color=#007700])*([/color][color=#0000bb]p[/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]"dien tich tam giac la s = " [/color][color=#007700]+[/color][color=#0000bb]s[/color][color=#007700]); [/color][color=#0000bb]sina [/color][color=#007700]= ([/color][color=#0000bb]2[/color][color=#007700]*[/color][color=#0000bb]s[/color][color=#007700])/([/color][color=#0000bb]b[/color][color=#007700]*[/color][color=#0000bb]c[/color][color=#007700]); [/color][color=#0000bb]sinb [/color][color=#007700]= ([/color][color=#0000bb]2[/color][color=#007700]*[/color][color=#0000bb]s[/color][color=#007700])/([/color][color=#0000bb]a[/color][color=#007700]*[/color][color=#0000bb]c[/color][color=#007700]); [/color][color=#0000bb]sinc [/color][color=#007700]= ([/color][color=#0000bb]2[/color][color=#007700]*[/color][color=#0000bb]s[/color][color=#007700])/([/color][color=#0000bb]a[/color][color=#007700]*[/color][color=#0000bb]b[/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]"goc a = " [/color][color=#007700]+[/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]todegrees[/color][color=#007700]([/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]asin[/color][color=#007700]([/color][color=#0000bb]sina[/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]"goc b = " [/color][color=#007700]+[/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]todegrees[/color][color=#007700]([/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]asin[/color][color=#007700]([/color][color=#0000bb]sinb[/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]"goc c = " [/color][color=#007700]+[/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]todegrees[/color][color=#007700]([/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]asin[/color][color=#007700]([/color][color=#0000bb]sinc[/color][color=#007700]))); }[/color] 
    </blockquote></div>
    </div>
    </div>

  8. #48
    Ngày tham gia
    Dec 2014
    Bài viết
    125
    thanks

  9. #49
    Ngày tham gia
    Apr 2015
    Bài viết
    0
    nộp bài ^^
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>

    show spoiler
    hide spoiler

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


    Mã nguồn PHP:
    [color=#000000]
    package edu[/color][color=#007700].[/color][color=#0000bb]ducky[/color][color=#007700].[/color][color=#0000bb]basic[/color][color=#007700]; public class [/color][color=#0000bb]bai1[/color][color=#007700]{ public static [/color][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]args[/color][color=#007700]) { [/color][color=#0000bb]int a[/color][color=#007700]=[/color][color=#0000bb]5[/color][color=#007700],[/color][color=#0000bb]b[/color][color=#007700]=[/color][color=#0000bb]6[/color][color=#007700],[/color][color=#0000bb]c[/color][color=#007700]=[/color][color=#0000bb]17[/color][color=#007700],[/color][color=#0000bb]result[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]result[/color][color=#007700]=[/color][color=#0000bb]a[/color][color=#007700]/[/color][color=#0000bb]2[/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]"phan nguyen cua a chia cho 2 la: "[/color][color=#007700]+ [/color][color=#0000bb]result[/color][color=#007700]); [/color][color=#0000bb]result[/color][color=#007700]=[/color][color=#0000bb]b[/color][color=#007700]/[/color][color=#0000bb]2[/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]"phan nguyen cua b chia cho 2 la:"[/color][color=#007700]+ [/color][color=#0000bb]result[/color][color=#007700]); [/color][color=#0000bb]result[/color][color=#007700]=[/color][color=#0000bb]c[/color][color=#007700]/[/color][color=#0000bb]2[/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]"phan nguyen cua c chia cho 2 la: "[/color][color=#007700]+ [/color][color=#0000bb]result[/color][color=#007700]); [/color][color=#0000bb]result[/color][color=#007700]=[/color][color=#0000bb]a[/color][color=#007700]%[/color][color=#0000bb]3[/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]"phan du cua a khi chia cho 3 la:" [/color][color=#007700]+ [/color][color=#0000bb]result[/color][color=#007700]); [/color][color=#0000bb]result[/color][color=#007700]=[/color][color=#0000bb]b[/color][color=#007700]%[/color][color=#0000bb]3[/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]"phan du cua a khi chia cho 3 la:" [/color][color=#007700]+ [/color][color=#0000bb]result[/color][color=#007700]); [/color][color=#0000bb]result[/color][color=#007700]=[/color][color=#0000bb]c[/color][color=#007700]%[/color][color=#0000bb]3[/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]"phan du cua a khi chia cho 3 la:" [/color][color=#007700]+ [/color][color=#0000bb]result[/color][color=#007700]); [/color][color=#0000bb]a[/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]"gia tri cua a moi la:"[/color][color=#007700]+ [/color][color=#0000bb]a[/color][color=#007700]); [/color][color=#0000bb]b[/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]"gia tri cua b moi la:"[/color][color=#007700]+ [/color][color=#0000bb]b[/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]"gia tri cua c moi la:"[/color][color=#007700]+ [/color][color=#0000bb]c[/color][color=#007700]); } }[/color] 
    </blockquote></div>
    </div>
    </div>
    bài 2:<div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>

    show spoiler
    hide spoiler

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


    Mã nguồn PHP:
    [color=#000000]
    package edu[/color][color=#007700].[/color][color=#0000bb]ducky[/color][color=#007700].[/color][color=#0000bb]basic[/color][color=#007700]; [/color][color=#ff8000]/**** @author windows xp*/[/color][color=#007700]public class [/color][color=#0000bb]bai2 [/color][color=#007700]{ [/color][color=#0000bb]float a[/color][color=#007700],[/color][color=#0000bb]b[/color][color=#007700],[/color][color=#0000bb]c[/color][color=#007700],[/color][color=#0000bb]x[/color][color=#007700]; public [/color][color=#0000bb]float giaipt[/color][color=#007700]([/color][color=#0000bb]float a[/color][color=#007700], [/color][color=#0000bb]float b[/color][color=#007700], [/color][color=#0000bb]float c[/color][color=#007700]){ [/color][color=#0000bb]x[/color][color=#007700]=([/color][color=#0000bb]8[/color][color=#007700]*[/color][color=#0000bb]c[/color][color=#007700]-[/color][color=#0000bb]b[/color][color=#007700])/([/color][color=#0000bb]2[/color][color=#007700]*[/color][color=#0000bb]a[/color][color=#007700]); return [/color][color=#0000bb]x[/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]float a[/color][color=#007700]=[/color][color=#0000bb]4.5f[/color][color=#007700],[/color][color=#0000bb]b[/color][color=#007700]=[/color][color=#0000bb]6.3f[/color][color=#007700],[/color][color=#0000bb]c[/color][color=#007700]=[/color][color=#0000bb]1.2f[/color][color=#007700]; [/color][color=#0000bb]bai2 bai2[/color][color=#007700]=new [/color][color=#0000bb]bai2[/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]"nghiem cua pt x="[/color][color=#007700]+ [/color][color=#0000bb]bai2[/color][color=#007700].[/color][color=#0000bb]giaipt[/color][color=#007700]([/color][color=#0000bb]a[/color][color=#007700], [/color][color=#0000bb]b[/color][color=#007700], [/color][color=#0000bb]c[/color][color=#007700])); [/color][color=#0000bb]int x1[/color][color=#007700]; [/color][color=#0000bb]x1[/color][color=#007700]=(int) [/color][color=#0000bb]bai2[/color][color=#007700].[/color][color=#0000bb]giaipt[/color][color=#007700]([/color][color=#0000bb]a[/color][color=#007700], [/color][color=#0000bb]b[/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]"nghiem nguyen cua pt la: "[/color][color=#007700]+ [/color][color=#0000bb]x1[/color][color=#007700]); } }[/color] 
    </blockquote></div>
    </div>
    </div>
    bai3: loai hoai..du kieu moi xong phan tinh goc...hieu thuan toán nhưng chưa hiểu cái thư viện math để tính cos :-(
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>

    show spoiler
    hide spoiler

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


    Mã nguồn PHP:
    [color=#000000]
    package edu[/color][color=#007700].[/color][color=#0000bb]ducky[/color][color=#007700].[/color][color=#0000bb]basic[/color][color=#007700]; [/color][color=#ff8000]/**** @author windows xp*/[/color][color=#007700]public class [/color][color=#0000bb]tamgiac [/color][color=#007700]{ [/color][color=#0000bb]int a[/color][color=#007700],[/color][color=#0000bb]b[/color][color=#007700],[/color][color=#0000bb]c[/color][color=#007700],[/color][color=#0000bb]p[/color][color=#007700],[/color][color=#0000bb]s[/color][color=#007700]; public [/color][color=#0000bb]int tinhdientich[/color][color=#007700]([/color][color=#0000bb]int a[/color][color=#007700],[/color][color=#0000bb]int b[/color][color=#007700],[/color][color=#0000bb]int c[/color][color=#007700]){ [/color][color=#0000bb]p[/color][color=#007700]=([/color][color=#0000bb]a[/color][color=#007700]+[/color][color=#0000bb]b[/color][color=#007700]+[/color][color=#0000bb]c[/color][color=#007700])/[/color][color=#0000bb]2[/color][color=#007700]; [/color][color=#0000bb]s[/color][color=#007700]=(int) [/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]sqrt[/color][color=#007700]([/color][color=#0000bb]p[/color][color=#007700]*([/color][color=#0000bb]p[/color][color=#007700]-[/color][color=#0000bb]a[/color][color=#007700])*([/color][color=#0000bb]p[/color][color=#007700]-[/color][color=#0000bb]b[/color][color=#007700])*([/color][color=#0000bb]p[/color][color=#007700]-[/color][color=#0000bb]c[/color][color=#007700])); return [/color][color=#0000bb]s[/color][color=#007700]; } public static [/color][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]args[/color][color=#007700]) { [/color][color=#0000bb]int a[/color][color=#007700]=[/color][color=#0000bb]3[/color][color=#007700],[/color][color=#0000bb]b[/color][color=#007700]=[/color][color=#0000bb]4[/color][color=#007700],[/color][color=#0000bb]c[/color][color=#007700]=[/color][color=#0000bb]5[/color][color=#007700]; [/color][color=#0000bb]double cosa[/color][color=#007700],[/color][color=#0000bb]cosb[/color][color=#007700],[/color][color=#0000bb]cosc[/color][color=#007700]; [/color][color=#0000bb]tamgiac tamgiac[/color][color=#007700]=new [/color][color=#0000bb]tamgiac[/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]"dien tich tam giac la: " [/color][color=#007700]+ [/color][color=#0000bb]tamgiac[/color][color=#007700].[/color][color=#0000bb]tinhdientich[/color][color=#007700]([/color][color=#0000bb]a[/color][color=#007700], [/color][color=#0000bb]b[/color][color=#007700], [/color][color=#0000bb]c[/color][color=#007700])); [/color][color=#0000bb]cosa[/color][color=#007700]=(float) ([/color][color=#0000bb]b[/color][color=#007700]*[/color][color=#0000bb]b[/color][color=#007700]+[/color][color=#0000bb]c[/color][color=#007700]*[/color][color=#0000bb]c[/color][color=#007700]-[/color][color=#0000bb]a[/color][color=#007700]*[/color][color=#0000bb]a[/color][color=#007700])/([/color][color=#0000bb]2[/color][color=#007700]*[/color][color=#0000bb]b[/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]"so do goc a="[/color][color=#007700]+ [/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]todegrees[/color][color=#007700]([/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]acos[/color][color=#007700]([/color][color=#0000bb]cosa[/color][color=#007700]))); [/color][color=#0000bb]cosb[/color][color=#007700]=(float)([/color][color=#0000bb]a[/color][color=#007700]*[/color][color=#0000bb]a[/color][color=#007700]+[/color][color=#0000bb]c[/color][color=#007700]*[/color][color=#0000bb]c[/color][color=#007700]-[/color][color=#0000bb]b[/color][color=#007700]*[/color][color=#0000bb]b[/color][color=#007700])/([/color][color=#0000bb]2[/color][color=#007700]*[/color][color=#0000bb]a[/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]"so do goac b="[/color][color=#007700]+ [/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]todegrees[/color][color=#007700]([/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]acos[/color][color=#007700]([/color][color=#0000bb]cosb[/color][color=#007700]))); [/color][color=#0000bb]cosc[/color][color=#007700]=(float)([/color][color=#0000bb]a[/color][color=#007700]*[/color][color=#0000bb]a[/color][color=#007700]+[/color][color=#0000bb]b[/color][color=#007700]*[/color][color=#0000bb]b[/color][color=#007700]-[/color][color=#0000bb]c[/color][color=#007700]*[/color][color=#0000bb]c[/color][color=#007700])/([/color][color=#0000bb]2[/color][color=#007700]*[/color][color=#0000bb]a[/color][color=#007700]*[/color][color=#0000bb]b[/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]"so do goc c="[/color][color=#007700]+ [/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]todegrees[/color][color=#007700]([/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]acos[/color][color=#007700]([/color][color=#0000bb]cosc[/color][color=#007700]))); } }[/color] 
    </blockquote></div>
    </div>
    </div>

  10. #50
    Ngày tham gia
    Feb 2015
    Bài viết
    0
    Mã nguồn PHP:
    [color=#000000]
    code [/color
    <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></blockquote></div>
    </div>
    </div>
    public class baitap2 {
    public static void main(string[]args){
    float a = 5.6f, b= 6.4f, c=9.6f,x;
    int songuyen;
    x=(8*c-b)/(2*a);
    system.out.println("ket qua phet tinh la:"+x);
    songuyen=(int) x;
    system.out.println("sau khi ep x la:"+(int)x);
    }

    }

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