Professional Documents
Culture Documents
BTC6
BTC6
int n;
int[] mang= new int[100];
Console.Write("Nhap so phan tu trong mang: ");
n = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < n; i++)
{
Console.Write("Phan tu {0}: ", i);
mang[i]= Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("Day cac phan tu vua nhap la:");
for (int i = 0; i < n; i++)
{
Console.Write("{0} ", i);
}
Console.WriteLine();
Console.WriteLine("In ra chieu nguoc lai");
for (int i = n -1; i >= 0; i--)
{
Console.Write("{0} ", mang[i]);
}
}
}
}
int i, j, n, dem = 1;
int[] mang = new int[100];
Console.Write("Nhap so phan tu trong mang: ");
n = int.Parse(Console.ReadLine());
for (i = 0; i < n; i++)
{
Console.Write("Phan tu {0}: ", i);
mang[i] = Convert.ToInt32(Console.ReadLine());
}
Console.Write("\nCac phan tu duy nhat duoc tim thay trong mang la: \n");
for (i = 0; i <=n; i++)
{
}
}
Câu 8:Chương trình C# để đếm số lần xuất hiện của từng phần tử trong mảng
Cách 1:
if (b[i] != 0)
{
b[i] = bien_dem;
}
}
Console.Write("\nTan suat xuat hien cua tung phan tu trong mang la: \n");
for (int i = 0; i < n; i++)
{
if (b[i] != 0)
{
Console.Write("Phan tu {0} xuat hien {1} lan\n", m[i], b[i]);
}
}
}
}
}
Cách 2:
int N;
Console.Write("Nhap so phan tu cua mang N: ");
N = Int32.Parse(Console.ReadLine());
Câu 12: Sắp xếp mảng theo thứ tự giảm dần trong C#
}
}
}
Câu 18: Đọc và in mảng hai chiều trong C#
Câu 23: Chương trình để tính tổng các phần tử trên đường chéo chính của ma trận