You are on page 1of 3

Bài 1:

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApp18
{
public abstract class SinhVien
{
private string tenSV;
private string maSV;

public SinhVien(string tenSV, string maSV)


{
this.tenSV = tenSV;
this.maSV = maSV;
}

public void Nhap()


{
Console.WriteLine("Nhap ten SV: ");
tenSV = Console.ReadLine();
Console.WriteLine("Nhap ma SV: ");
maSV = Console.ReadLine();
}
public abstract string toString();
}
}
Bài 2:
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApp18
{
public class SoHuuTi
{
private double a;
private double b;

public SoHuuTi() { }
public SoHuuTi(double a, double b)
{
this.a = a;
this.b = b;
}

public static SoHuuTi operator + (SoHuuTi s1, SoHuuTi s2)


{
SoHuuTi tong = new SoHuuTi();
tong.a = s1.a * s2.b + s2.a * s1.b;
tong.b = s1.b * s2.b;
return tong;
}
public static SoHuuTi operator - (SoHuuTi s1, SoHuuTi s2)
{
SoHuuTi hieu = new SoHuuTi();
hieu.a = s1.a * s2.b - s2.a * s1.b;
hieu.b = s1.b * s2.b;
return hieu;
}

public static SoHuuTi operator * (SoHuuTi s1, SoHuuTi s2)


{
SoHuuTi tich = new SoHuuTi();
tich.a = s1.a * s2.a;
tich.b = s1.b * s2.b;
return tich;
}

public static SoHuuTi operator / (SoHuuTi s1, SoHuuTi s2)


{
SoHuuTi thuong = new SoHuuTi();
thuong.a = s1.a * s2.b;
thuong.b = s1.b * s2.a;
return thuong;
}
}
}
Bài 3:
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApp18
{
public class MyIntArray
{
private int[] a;
//private int n;

public MyIntArray() { }
public MyIntArray(int[] a)
{
this.a = a;
}
public void NhapMang()
{
//Console.Write("Nhap so phan tu: ");
//n = int.Parse(Console.ReadLine());
Console.Write("Nhap array: ");
string[] s = Console.ReadLine().Split();
a = new int[s.Length];
for (int i=0; i<s.Length; i++)
{
a[i] = int.Parse(s[i]);
}
}
public void XuatMang()
{
for (int i=0; i<a.Length; i++)
{
Console.Write(a[i] + " ");
}
}

public int Min()


{
int min = a[0];
for (int i=1; i<a.Length; i++)
{
if (min > a[i]) min = a[i];
}
return min;
}

}
}
Bài 4:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace ConsoleApp18
{
public class MyArray
{
private ArrayList a;

public MyArray() { }

public MyArray(ArrayList a)
{
this.a = a;
}
public void ThemPT(object s)
{
a.Add(s);
}

}
}

You might also like