BAITAP_DAY5.docx

Console writeline 1 nhân 2 s ố console writeline 2

This preview shows page 4 - 7 out of 7 pages.

Console .WriteLine (“1. Nhân 2 s ”); Console .WriteLine (“2. Chia 2 s ”); Console .WriteLine (“3. C ng 2 s ”); Console .WriteLine (“4. Tr 2 s ”); Console .WriteLine (“5. Thoát”); Console .WriteLine (“M i b n ch n :”); chon = Convert .ToInt16( Console .ReadLine()); switch(chon) { case 1: kq=nhan2so(a,b); //In ket qua phep nhan; break; case 2: kq=chia2so(a,b); // In ket qua phep chia; break;
Image of page 4

Subscribe to view the full document.

case 3: kq=cong2so(a,b); //In ket qua phep cong; break; case 4: kq=tru2so(a,b); // In ket qua phep tru; break; case 5: break; } }while(chon!=5); } static int nhan2so(int a,int b) { int nhan=a*b; return nhan; } static int chia2so(int a,int b) { ...... } static int cong2so(int a,int b) { ...... } static int tru2so(int a,int b) { ...... } 1.7 BÀI T P 7 1. Th i l ng: ượ 15 phút 2. Mô t bài toán: Vi t ch ng trình nh p s nguyên d ng n , ki m tra xem n có ph i là s nguyên t . ế ươ ươ 3. G i ý: static void Main(string[] args) { Nh p vào 1 s x int kq = ktnguyento(x); N u (kq==1) ế { ………………. } else …………………
Image of page 5
} static int ktnguyento(int k) { int dem=0; for(int i=1;i<=k;i++) { if(k%i==0) dem++; } if(dem==2) return 1; return 0; } 1.8 BÀI T P 8 1. Th i l ng: ượ 15 phút 2. Mô t bài toán: Vi t ch ng trình nh p s nguyên d ng n g m k ch s ế ươ ươ ữ ố ( 0<k<5),tính t ng các c s c a n ướ 3. Các b c th c hi n: ướ static int tongUocSo(int n) { …… return tong; } 1.9 1.10 BÀI T P 9 * 1. Th i l ng: ượ 15 phút 2. Mô t bài toán: Nh p vào 3 s th c a, b, c và ki
Image of page 6

Subscribe to view the full document.

Image of page 7
  • Fall '19

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern