public static TRALOI KhoiTao(BIEUTHUC P, Random t) { TRALOI kq; kq.NoiDung = ""; long k = XuLyBieuThuc.TinhToan(P) + t.Next() % 100; kq.NoiDung = k.ToString(); return(kq); }
public static CAUHOI KhoiTao(BIEUTHUC P, Random t) { CAUHOI kq; kq.NoiDung = XuLyBieuThuc.XuatChuoi(P); kq.TraLoi = new TRALOI[n_traloi]; for (int i = 0; i < n_traloi; i++) { kq.TraLoi[i] = XuLyTraLoi.KhoiTao(P, t); } kq.TraLoi[t.Next() % n_traloi].NoiDung = XuLyBieuThuc.TinhToan(P).ToString(); return(kq); }
public static long TraLoiCauHoi(CAUHOI P) { Boolean flag = true; BIEUTHUC Q = XuLyBieuThuc.KhoiTao(P.NoiDung); long t = XuLyBieuThuc.TinhToan(Q); for (int i = 0; i < P.TraLoi.Length; i++) { if (t == long.Parse(P.TraLoi[i].NoiDung)) { return(i + 1); } } return(-1); }
static void Main(string[] args) { BIEUTHUC[] NoiDung; CAUHOI[] De; NoiDung = XuLyBieuThuc.Nhap("Nhap vao noi dung cac cau hoi:\n"); De = new CAUHOI[NoiDung.Length]; String Chuoi = ""; Random t = new Random(); for (int i = 0; i < NoiDung.Length; i++) { De[i] = XuLyCauHoi.KhoiTao(NoiDung[i], t); Chuoi = Chuoi + XuLyCauHoi.XuatChuoi(De[i]); if (i < NoiDung.Length - 1) { Chuoi += "\r\n"; } } XuLyTapTin.Ghi("DeThiTracNghiem.txt", Chuoi); XuLyChuoi.Xuat(Chuoi); }