bài 31, 32

//bai 31 DATHUC Tich(DONTHUC a, DATHUC b){ DATHUC temp; int index = 0; for(int i = 0; i < b.pt; i++){ temp.dt[index].k = b.dt[i].k * a.k; temp.dt[index].n = b.dt[i].n + a.n; index++; } temp.pt = index; return temp; } void SapMuGiam(DATHUC a){ for(int i = 0; i < a.pt - 1; i++) for(int j = i + 1; j < a.pt; j++) if(a.dt[i].n > a.dt[j].n){ DONTHUC t = a.dt[i]; a.dt[i] = a.dt[j]; a.dt[j] = t; } } DATHUC Thuong(DATHUC a, DATHUC b){ SapMuGiam(a); SapMuGiam(b); DATHUC temp, m = a, n = b; int s = 0; while(m.dt[s].n >= n.dt[0].n){ temp.dt[s] = m.dt[s] / n.dt[0]; m = ChuanHoa( Hieu(m, Tich(temp.dt[s], n) ) ); s++; } temp.pt = s; return temp; } //bai 32 DATHUC Du(DATHUC a, DATHUC b){ return Hieu(a, Tich(b, Thuong(a, b) ) ); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.