Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ktlt
- {
- class Class5
- {
- struct PhanSo
- {
- public int TuSo;
- public int MauSo;
- }
- static PhanSo NhapPhanSo(string ghichu)
- {
- Console.WriteLine(ghichu);
- PhanSo kq;
- Console.WriteLine("nhap tu so");
- kq.TuSo = int.Parse(Console.ReadLine());
- Console.WriteLine("nhap mau so");
- kq.MauSo = int.Parse(Console.ReadLine());
- return kq;
- }
- static PhanSo Cong2PS(PhanSo a, PhanSo b)
- {
- PhanSo kq;
- kq.TuSo = a.TuSo * b.MauSo + a.MauSo * b.TuSo;
- kq.MauSo = a.MauSo * b.MauSo;
- //Console.Write(kq);
- return kq;
- }
- static string XuatPhanSo(PhanSo kq)
- {
- return string.Format("{0}/{1}", kq.TuSo, kq.MauSo);
- }
- static void Main(string[] args)
- {
- PhanSo a, b;
- a = NhapPhanSo("nhap phan so a");
- b = NhapPhanSo("nhap phan so b");
- PhanSo kq=Cong2PS(a, b);
- string chuoi = "ket qua la " + XuatPhanSo(kq);
- Console.WriteLine(chuoi);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement