Tong Hop Bai Tap C

  • View
    110

  • Download
    0

Embed Size (px)

DESCRIPTION

 

Transcript

  • 1. Dang Tu Nam Tng hp cc bi tp C/C++ Mc lc:Part 11. M HA THNG IP 2. GII PHNG TRNH BC NHT 3. TNH CN BC HAI THEO PHNG PHP LP NEWTON 4. CU TRC V CC HM THAO TC TRN S PHC 5. DY TNG DN 6. DY TNG C TNG DI NHT 7. QUN L SINH VIN 8. GII PHNG TRNH BC HAI 9. MA PHNG 10.FILE V H THNG Part 21. SP XP MNG 2. Mt v d v a hnh 3. Tip mt v d v a hnh 4. Tng hai ma trn 5. Mt v d v s dng template v qu ti ton t Nhp xut 6. V d v qu ti ton t 7. m s ln xut hin ca cc k t trong chui 8. Bi ton Ancarokhi 9. Chng minh ng thc An Casi 10.Hin bng m ASCII 11.In ra nm m lch tng ng vi nm nhp vo. 12.In ra bng cu chng 13.Nhp chui v in chui 14.Gii h phng trnh bc nht. 15.Tnh th ca ngy Part 31. Chuyn s La M sang s rp 2. Chuyn nm sang s La M 3. Thut ton sp xp bng Radix sort 4. Danh sch lin kt n (Thut ton va chn va sp xp) 5. Qu ti ton t nhp xut v s dng template 6. Chng trnh m s k t trong mt chui ASCII 7. Biu din s di dng bit 8. o chui 9. Chng trnh xem tp tin 10.Gii bi ton tru n c 11.Loi b khong trng tha trong chui 12.Tm tt c cc c ca mt s N 13.Bi s chung v c s chung 14.Trn 2 dy gim thnh mt dy tng 15.Tnh tch 2 ma trn: 16.In danh sch cc s hon ho nh hn s N nhp t user Part 41. Bi in ra lch ca mt nm bt k ln hn 1700 2. Bi tp kim tra du ngoc ng. 3. Bi ton Tm Hong Hu 4. In ra s Hex tng ng vi mt s nguyn dng 5. Lit k cc hon v ca N phn t 6. In chui theo cc t mi t mt dng 7. In ra ch s hng trm hng chc hng n v 8. Tm phn t ln nht nh nht trong mng mt chiu 9. Tnh t hp chp K ca N phn t 10.Chng trnh c s c 1,2 hoc 3 ch s.

2. Dang Tu Nam11. Tnh s ngy trong mt thng trong mt nm bt k12. Bi kim tra s nguyn t13. Tm max min ca 4 s14. Tm n s Fibonaci u tin Part 51.(Ngn hng)Tm s tin nhn trong n thng khi bit li xut 2.In ra dy s ngc so vi dy s nhp vo 3.Tr chi 8 hn bi 4.Kim tra s i xng 5.in gi tr cho mt mng vung theo chiu kim ng h 6.In hnh tam gic 7.Trn hai mng tng dn thnh mt mng tng dn 8.Tm v tr u v v tr cui ca mt s trong mt dy s 9.Tnh x^1/1! + x^2/2! + x^3/3! + ... + x^n/n! 10. Trnh by cc bc chuyn n a t cc A sang cc C trong bi ton Thp H Ni dng 3 a 11. Trnh by cc bc chuyn n a t cc A sang cc C trong bi ton Thp H Ni dng 4 a 3. Dang Tu NamM HA THNG IPCode: #include #include #include char *crypt(char *tdiep, int column) { char tam[255], *result; int i = 0, k = 0, n, j=0;while(tdiep[i] != 0) { if (isalnum(tdiep[i])) tam[k++] = tdiep[i]; i++; } tam[k] = 0; result = (char *)malloc(k+1); for (i=0; ivoid main() { float a, b;printf(quot;nGiai phuong trinh bac nhat AX + B = 0quot;); printf(quot;nCho biet ba he so A B : quot;); scanf(quot;%f%fquot;, &a, &b);if (a==0) if (b!=0) printf(quot;Phuong trinh vo nghiemquot;); else printf(quot;Phuong trinh co nghiem khong xac dinhquot;); else printf(quot;Dap so cua phuong trinh tren = %fquot;, -b/a); getch(); } 4. Dang Tu Nam TNH CN BC HAI THEO PHNG PHP LP NEWTON Code: #include #include void main() { double a, xn, ketqua;printf(quot;nNhap vao so muon tinh can bac hai : quot;); scanf(quot;%lfquot;, &a); xn = (a+1)/2; do { ketqua = xn; xn = 0.5 * (xn + a/xn); } while (fabs(xn-ketqua) > 0.0001); printf(quot;nKet qua = %lfquot;, xn); getch(); }CU TRC V CC HM THAO TC TRN S PHCCode: #include typedef struct tagcomplex { float thuc, ao; } complex;complex tong(complex a, complex { complex c; c.thuc = a.thuc + b.thuc; c.ao = a.ao + b.ao; return c; }complex hieu(complex a, complex { complex c; c.thuc = a.thuc - b.thuc; c.ao = a.ao - b.ao; return c; }complex tich(complex a, complex { complex c; c.thuc = a.thuc*b.thuc - a.ao*b.ao; c.ao = a.thuc*b.ao + a.ao*b.thuc; return c; }complex thuong(complex a, complex { complex c; float tongbp; tongbp = b.thuc*b.thuc + b.ao*b.ao; c.thuc = (a.thuc*a.ao + b.thuc*b.ao)/tongbp; c.ao = (a.ao*b.thuc - a.thuc*b.ao)/tongbp; return c; }float argument(complex a) { return acos(a.thuc/sqrt(a.thuc*a.thuc + a.ao*a.ao)); }float modul(complex a) 5. Dang Tu Nam { return sqrt(a.thuc*a.thuc + a.ao*a.ao); }void print_complex(complex a) { printf(quot;%.2f + %.2fiquot;, a.thuc, a.ao); }void main() { complex a, b, c; printf(quot;nNhap he so thuc va phuc cua A : quot;); scanf(quot;%f%fquot;, &a.thuc, &a.ao); printf(quot;nNhap he so thuc va phuc cua B : quot;); scanf(quot;%f%fquot;, &b.thuc, &b.ao); printf(quot;nSo phuc A = quot;); print_complex(a); printf(quot;nSo phuc B = quot;); print_complex( ; printf(quot;nTong cua chung = quot;); c = tong(a, ; print_complex; printf(quot;nHieu cua chung = quot;); c = hieu(a, ; print_complex; printf(quot;nTich cua chung = quot;); c = tich(a, ; print_complex; printf(quot;nThuong cua chung = quot;); c = thuong(a, ; print_complex; printf(quot;nArgument cua a = %fquot;, argument(a)); printf(quot;nModul cua a = %fquot;, modul(a)); getch(); } DY TNG DN Code: #include void main() { int a[10], i, maxstart, maxend, maxlen, tmpstart, tmpend, tmplen;printf(quot;nNhap vao 10 phan tu nguyen cua day :quot;); for (i=0; i