Ejemplo n.º 1
0
    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);
    }
    private static BIEUTHUC NhapCucBo(String GhiChu)
    {
        String Chuoi;

        do
        {
            Chuoi = XuLyChuoi.Nhap(GhiChu);
        } while (!KiemTra(Chuoi));
        BIEUTHUC kq = KhoiTao(Chuoi);

        return(kq);
    }
Ejemplo n.º 3
0
    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 BIEUTHUC[] Nhap(String GhiChu)
    {
        BIEUTHUC[] kq;
        XuLyChuoi.Xuat(GhiChu);
        long n;

        n  = XuLySoNguyen.Nhap("Ban muon tao bao nhieu cau hoi?", 1, 100);
        kq = new BIEUTHUC[n];
        for (int i = 0; i < n; i++)
        {
            kq[i] = NhapCucBo("Nhap bieu thuc thu " + (i + 1) + ":");
        }
        return(kq);
    }
Ejemplo n.º 5
0
    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);
    }
    public static long TinhToan(BIEUTHUC P)
    {
        long kq = 0;

        switch (P.PhepToan)
        {
        case PHEPTOAN.CONG:
            kq = P.So1 + P.So2;
            break;

        case PHEPTOAN.TRU:
            kq = P.So1 - P.So2;
            break;

        case PHEPTOAN.NHAN:
            kq = P.So1 * P.So2;
            break;
        }
        return(kq);
    }
    public static String XuatChuoi(BIEUTHUC P)
    {
        String kq;

        kq = P.So1 + " _ " + P.So2;
        switch (P.PhepToan)
        {
        case PHEPTOAN.CONG:
            kq = kq.Replace("_", "+");
            break;

        case PHEPTOAN.TRU:
            kq = kq.Replace("_", "-");
            break;

        case PHEPTOAN.NHAN:
            kq = kq.Replace("_", "*");
            break;
        }
        return(kq);
    }