CÁC CẤU TRÚC LẶP ( WHILE - DO WHILE - FOR).pdf

Vd n 10 sn 1 3 5 7 9 25 bài 4 vi ết chương

Info icon This preview shows pages 4–5. Sign up to view the full content.

View Full Document Right Arrow Icon
VD: n = 10 ==> S(n) = 1 + 3 + 5 + 7 + 9 = 25 Bài 4 . Vi ết chương trình kiể m tra xem n có ph i là s chính phương hay không ? Vớ i n là s nguyên nh p t bàn phím. Demo code Bài 1 #include <iostream> using namespace std; int main( int argc, char **argv) { int n; cout << "\nNhap gia tri n: " ; cin >> n; int s = 0; // kh i t o bi ến s để c ng d n t 1 đế n n for ( int i = 1; i <= n; i++) { s = s + i; // m i l n l p thì th c hi n công vi c c ng d n } cout << "\nTong 1 den " << n << " la: " << s; system( "pause" ); return 0; }
Image of page 4

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Nguy n Thi n Tâm Facebook: SĐT: 09357 34548 --------------------------------------------------------------------- END --------------------------------------------------------------------- - Đây là tài liệu dùng để h c và tham kh o. - Trong quá trình biên so n b tài li u có: + Tham kh o 1 s ngu n tài li ệu(google search, ebook, sách chuyên ngành…). + Ki ế n th c kinh nghi m cá nhân c a tôi. - Có th còn 1 s l i sai sót s luôn c p nh t phiên b n m i. - Mong nh ận đượ c s đóng góp và phả n h i tích c c t các b ạn đọ c. Chân thành c ảm ơn .
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ 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