public static void Main(string[] args) { PHAN_SO A; PHAN_SO B; QUAN_HE kq; A = XL_PHAN_SO.Nhap("Nhap phan so A:\n"); B = XL_PHAN_SO.Nhap("Nhap phan so B:\n"); kq = XL_PHAN_SO.So_sanh(A, B); String Chuoi; Chuoi = XL_PHAN_SO.Chuoi(A) + "kq" + XL_PHAN_SO.Chuoi(B); if (kq == QUAN_HE.Nho_hon) { Chuoi = Chuoi.Replace("kq", "<"); } else if (kq == QUAN_HE.Bang_nhau) { Chuoi = Chuoi.Replace("kq", "="); } else if (kq == QUAN_HE.Lon_hon) { Chuoi = Chuoi.Replace("kq", ">"); } XL_CHUOI.Xuat(Chuoi); }
static void Main(string[] args) { PHAN_SO A, B, kq; A = XL_PHAN_SO.Nhap("Nhap phan so thu nhat:\n"); B = XL_PHAN_SO.Nhap("Nhap phan so thu hai:\n"); kq = XL_PHAN_SO.Tich(A, B); String Chuoi; Chuoi = XL_PHAN_SO.Chuoi(A) + " * "; Chuoi = Chuoi + XL_PHAN_SO.Chuoi(B) + " = "; Chuoi = Chuoi + XL_PHAN_SO.Chuoi(kq); XL_CHUOI.Xuat(Chuoi); }
public static PHAN_SO Max(ArrayList Ps) { PHAN_SO kq; kq = (PHAN_SO)Ps[0]; foreach (PHAN_SO x in Ps) { if (XL_PHAN_SO.So_sanh(x, kq) == QUAN_HE.Lon_hon) { kq = x; } } return(kq); }
public static void Main(string[] args) { BIEU_THUC P; PHAN_SO kq; P = XL_BIEU_THUC.Nhap("Nhap vao 1 bieu thuc phan so:\n"); kq = XL_BIEU_THUC.Tinh(P); String Chuoi = ""; Chuoi = Chuoi + XL_BIEU_THUC.Chuoi(P) + " = "; Chuoi = Chuoi + XL_PHAN_SO.Chuoi(kq); XL_CHUOI.Xuat(Chuoi); }
public static void Main(string[] args) { ArrayList Ps; PHAN_SO kq; Ps = XL_DAY_PHAN_SO.Nhap("Nhap vao day phan so:\n"); kq = XL_DAY_PHAN_SO.Max(Ps); String Chuoi = "Day cac phan so "; Chuoi = Chuoi + XL_DAY_PHAN_SO.Chuoi(Ps) + "\n"; Chuoi = Chuoi + "co phan so lon nhat la "; Chuoi = Chuoi + XL_PHAN_SO.Chuoi(kq); XL_CHUOI.Xuat(Chuoi); }
public static String Chuoi(ArrayList Ps) { String kq = ""; for (int i = 0; i < Ps.Count; i++) { PHAN_SO x = (PHAN_SO)Ps[i]; kq = kq + XL_PHAN_SO.Chuoi(x); if (i < Ps.Count - 1) { kq = kq + Ky_tu_phan_cach; } } return(kq); }
public static ArrayList Nhap(String Ghi_chu) { ArrayList kq = new ArrayList(); String Chuoi; do { Chuoi = XL_CHUOI.Nhap(Ghi_chu); } while (!Kiem_tra(Chuoi)); String[] M = Chuoi.Split(new char[] { Ky_tu_phan_cach }); for (int i = 0; i < M.Length; i++) { kq.Add(XL_PHAN_SO.Tao(M[i])); } return(kq); }
public static BIEU_THUC Nhap(String Ghi_chu) { BIEU_THUC kq; long n; XL_CHUOI.Xuat(Ghi_chu); n = XL_SO_NGUYEN.Nhap("Bieu thuc co bao nhieu so hang:"); kq.So_hang = new PHAN_SO[n]; kq.Toan_tu = new TOAN_TU[n - 1]; char c; kq.So_hang[0] = XL_PHAN_SO.Nhap("Nhap so hang thu 1 : \n"); for (int i = 1; i < n; i++) { kq.Toan_tu[i - 1] = XL_TOAN_TU.Nhap("Nhap toan tu thu " + i + " : "); kq.So_hang[i] = XL_PHAN_SO.Nhap("Nhap so hang thu " + (i + 1) + " : "); } return(kq); }
public static PHAN_SO Tinh(BIEU_THUC P) { PHAN_SO kq; kq = P.So_hang[0]; for (int i = 1; i < P.So_hang.GetLength(0); i++) { if (P.Toan_tu[i - 1] == TOAN_TU.Cong) { kq = XL_PHAN_SO.Tong(kq, P.So_hang[i]); } else if (P.Toan_tu[i - 1] == TOAN_TU.Tru) { kq = XL_PHAN_SO.Hieu(kq, P.So_hang[i]); } } return(kq); }
public static String Chuoi(BIEU_THUC P) { String kq = ""; kq = kq + XL_PHAN_SO.Chuoi(P.So_hang[0]); for (int i = 1; i < P.So_hang.GetLength(0); i++) { if (P.Toan_tu[i - 1] == TOAN_TU.Cong) { kq = kq + " + "; } else if (P.Toan_tu[i - 1] == TOAN_TU.Tru) { kq = kq + " - "; } kq = kq + XL_PHAN_SO.Chuoi(P.So_hang[i]); } return(kq); }
public static Boolean Kiem_tra(String Chuoi) { Boolean kq = true; try { String[] M = Chuoi.Split(new char[] { Ky_tu_phan_cach }); for (int i = 0; i < M.Length; i++) { if (!XL_PHAN_SO.Kiem_tra(M[i])) { kq = false; break; } } } catch (Exception Loi) { kq = false; } return(kq); }