Professional Documents
Culture Documents
Câu 1
Câu 1
using System;
namespace HongNguyen
{
class Program
{
static void Main(string[] args)
{
Console.OutputEncoding = System.Text.Encoding.UTF8;
Console.WriteLine("Nhập 3 chữ cái và hiển thị theo chiều ngược lại:");
string a = Console.ReadLine();
string b = Console.ReadLine();
string c = Console.ReadLine();
Console.WriteLine("3 chữ cái hiển thị theo chiều ngược lại: {0}, {1}, {2}",
c, b, a);
}
}
}
}
}
Console.OutputEncoding = System.Text.Encoding.UTF8;
int n, i, j;
Console.WriteLine("Vẽ tam giác vuông:");
Console.Write("Nhap so hang: ");
n = Convert.ToInt32(Console.ReadLine());
for ( i = 0; i <= n; i++)
{
for ( j = 0; j < i; j++)
Console.Write(j);
Console.Write("\n");
}
Câu 3.
Console.OutputEncoding = System.Text.Encoding.UTF8;
string system_usernam = "HongNguyen", system_password = "1511";
Console.WriteLine("Hãy nhập usernam và password");
string username = Console.ReadLine();
string password = Console.ReadLine();
if (username == system_usernam && password == system_password)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Bạn đã đăng nhập thành công");
}
else
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Bạn đã đăng nhập thất bại");
}
Câu 6.
double chu_vi, s, r;
double PI = 3.14;
Console.OutputEncoding = System.Text.Encoding.UTF8;
Console.WriteLine("Hãy nhập bán kính r:");
r =int.Parse (Console.ReadLine());
chu_vi = 2 * PI * r;
Console.WriteLine("Chu vi hình tròn là {0}", chu_vi);
s = PI * Math.Pow(r, 2);
Câu 7
double y;
Console.OutputEncoding = System.Text.Encoding.UTF8;
Console.WriteLine("Giải phương trình:y=a*x*x+b*x+c");
Console.Write("a=\n");
double a = double.Parse(Console.ReadLine());
Console.Write("b=\n");
double b = double.Parse(Console.ReadLine());
Console.Write("c=\n");
double c = double.Parse(Console.ReadLine());
Console.Write("x=\n");
double x = double.Parse(Console.ReadLine());
y = a * Math.Pow(x, 2) + b * x + c;
Console.WriteLine("Phương trình y có giá trị là: {0}", y);
Câu 8
Câu 9
double r, s, v;
double PI = 3.14;
Console.OutputEncoding = System.Text.Encoding.UTF8;
Console.Write("Nhập bán kính hình cầu r: ");
r = float.Parse(Console.ReadLine());
s = 4 * PI * Math.Pow(r, 2);
Console.ForegroundColor = ConsoleColor.DarkBlue;
Console.WriteLine("Diện tích hình cầu là: {0}", s);
v = (4 / 3 )* PI * Math.Pow(r, 3);
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.WriteLine("Thể tích hình cầu là: {0}", v);
Câu 10
char ch;
Console.OutputEncoding = System.Text.Encoding.UTF8;
Console.WriteLine("Hãy nhập kí tự bất kì:");
ch = Convert.ToChar(Console.ReadLine());
if (ch >= 'a' && ch <= 'z')
Console.WriteLine("Chu cai in thuong");
else if (ch >= 'A' && ch <= 'Z')
Console.WriteLine("Chu cai in hoa");
else if (ch >= '1' && ch <= '9')
Console.WriteLine("Chu so");
else
Console.WriteLine("Ki tu dac biet");
Cách 2
char symbol;