C2_Basics_of_C_and_Cpp - Chng 1 K thut lp trnh Chng 2: Cc...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
© 2004, HOÀNG MINH S Ơ N Ch ươ ng 1 K thu t l p trình 0101010101010101100001 0101010101010101100001 0101010101010101100001 0101010100101010100101 0101010100101010100101 0101010100101010100101 1010011000110010010010 1010011000110010010010 1010011000110010010010 1100101100100010000010 1100101100100010000010 1100101100100010000010 0101010101010101100001 0101010101010101100001 0101010101010101100001 0101010100101010100101 0101010100101010100101 0101010100101010100101 1010011000110010010010 1010011000110010010010 1010011000110010010010 1100101100100010000010 1100101100100010000010 1100101100100010000010 0101010101010101100001 0101010101010101100001 0101010101010101100001 0101010100101010100101 0101010100101010100101 0101010100101010100101 1010011000110010010010 1010011000110010010010 1010011000110010010010 1100101100100010000010 1100101100100010000010 1100101100100010000010 8/19/2006 y = A*x + B*u; x = C*x + d*u; StateController start() stop() LQGController start() stop() Ch ươ ng 2: Các y ế ut c ơ b n c aC ±vàC++
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 © 2004, HOÀNG MINH S Ơ N Ch ươ ng 2: Các y ế ut c ơ b nc aC±vàC++ N idung ch ươ ng 2 2.1 T ch cch ươ ng trình C/C++ 2.2 Bi ế nvàcácki ud li uc ơ b n 2.3 Các ki li nxu ttr cti ế p 2.4 Đị nh ngh ĩ aki li um i 2.5 Đ i ukhi nch ươ ng trình: phân nhánh 2.6 Đ i ươ ng trình: vòng l p 2.7 M ts l nh i ươ ng trình khác
Background image of page 2
3 © 2004, HOÀNG MINH S Ơ N Ch ươ ng 2: Các y ế ut c ơ b nc aC±vàC++ 2.1 T ch c ch ươ ng trình C/C++ ± C utrúcvàcácph nt c ơ b am tch ươ ng trình vi ế ttrênC/C++ ± Qui trình t oram ươ ng trình ch y ₫ượ c: —V n ₫ề t od án —Qu i t cso nth omãngu n —B i ênd ch t ng ph nvàs acáclo il ibiênd ch —L i ênk ế tvàs d ng th ư vi n, s al iliênk ế t —Ch yth và g r i(Debug) ± S ơ l ượ cv t ch cb nh
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 © 2004, HOÀNG MINH S Ơ N Ch ươ ng 2: Các y ế ut c ơ b nc aC±vàC++ 2.1 T ch c ch ươ ng trình C/C++ Ch ươ ng trình (CT) # Ti n x Thân hàm chính void main() { } Khai báo bi ế n, hàm . .. Đị nh ngh ĩ a hàm (thân hàm) Khai báo th ư vi n và macro Khai báo hàm ₫ượ c s d ng trong CT chính Ch ươ ng trình chính Đị nh ngh ĩ a thân hàm ã khai báo
Background image of page 4
5 © 2004, HOÀNG MINH S Ơ N Ch ươ ng 2: Các y ế ut c ơ b nc aC±vàC++ Ch ươ ng trình tính giai th a: Phiên b nC #include <stdio.h> #include <conio.h> int factorial(int); void main () { char c = 'N'; int N = 1; int kq; do { printf(“\nEnter a number > 0:"); /* writing on the screen */ scanf("%d",&N); /* reading from keyboard to N */ kq = factorial(N); /* calling function with argument N */ printf(“\nFactorial of %d is %d", N, kq); /*write result on screen */ printf(“\nPress 'Y' to continue or any other key to stop"); c = getch(); /* reading a character from keyboard*/ } while (c=='y' || c=='Y'); /* checking loop condition */ } int factorial(int n) { int kq = 1; while (n > 1) kq *= n--; return kq; }
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 © 2004, HOÀNG MINH S Ơ N Ch ươ ng 2: Các y ế ut c ơ b nc aC±vàC++ Ch ươ ng trình tính giai th a: Phiên b nC++ #include <iostream.h> #include <conio.h> int factorial(int); void main () { char c = 'N'; int N = 1; do { cout << “\nEnter a number > 0:“ // writing on the screen cin >> N; // reading from keyboard to N int kq = factorial(N); // calling function with argument cout << “\nFactorial of ” << N << “ is “ << kq cout << “\nPress 'Y' to continue or any other key to stop"; c = getch(); // reading a character from keyboard } while (c == 'y' || c == 'Y'); // checking loop condition } int factorial(int n) { int kq = 1; while (n > 1) kq *= n--; return kq; }
Background image of page 6
7 © 2004, HOÀNG MINH S Ơ N Ch ươ ng 2: Các y ế ut c ơ b nc aC±vàC++ T od án 1 2 3 4
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 66

C2_Basics_of_C_and_Cpp - Chng 1 K thut lp trnh Chng 2: Cc...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online