Bạn có muốn phản ứng với tin nhắn này? Vui lòng đăng ký diễn đàn trong một vài cú nhấp chuột hoặc đăng nhập để tiếp tục.

Một số bài ôn tập C# của lớp luyện thi đầu vào

3 posters

Go down

Một số bài ôn tập C# của lớp luyện thi đầu vào Empty Một số bài ôn tập C# của lớp luyện thi đầu vào

Bài gửi by liongak 7/1/2010, 23:35

Ngày xửa ngày xưa khi đi ôn thi vào trường Đại học Kinh Tế (hồi nữa năm trước).Cô giáo có cho 1 đống bài tập ôn, tui có giải 1 ít bài nhưng lâu quá đề quăng mất tiêu rồi. Bỏ lên đây bác nào cần coi cho vui thì nghía qua hen.Khà khà, chúc bà con học tốt.
Phần 1: http://www.mediafire.com/?yyzgmdtz0mm
Phần 2: http://www.mediafire.com/?mljwuyj3z22


Được sửa bởi liongak ngày 13/1/2010, 16:17; sửa lần 1.
liongak
liongak
Cống hiến
Cống hiến

Tổng số bài gửi : 202
Join date : 16/09/2009
Age : 37
Đến từ : Thanh Hóa

Về Đầu Trang Go down

Một số bài ôn tập C# của lớp luyện thi đầu vào Empty Re: Một số bài ôn tập C# của lớp luyện thi đầu vào

Bài gửi by liongak 7/1/2010, 23:37

using System;
using System.Collections.Generic;
using System.Text;
using System.Security;
namespace bt
{
class Program
{
static void inhcm(int d, int r,int a,int b)
{
Console.SetCursorPosition(a, b);
for (int i = 0; i < r; i++)
{


Console.SetCursorPosition(a, b+i);
for (int j = 0; j < d; j++)
{

if (i == 0 || i == r - 1)
Console.Write('*');
else
if (j == 0 || j == d - 1)
Console.Write('*');
else
Console.Write(' ');
}
Console.Write("\n");
}
}

static void Main(string[] args)
{
do{
/*
string s1 = " ";
Console.WriteLine(s1.PadLeft(30, '-') + "\n\n\t\tHoa don tien dien\n\nKhach hang : " + s);
*/

/*Câu 4/3
Console.Write("Nhap cac he so cho he phuong trinh \n\ta1x+b1y=c1\n\ta2x+b2y=c2\na1=");
int a1 =Int32.Parse(Console.ReadLine());
Console.Write("b1=");
int b1 = Int32.Parse(Console.ReadLine());
Console.Write("c1=");
int c1 = Int32.Parse(Console.ReadLine());
Console.Write("a2=");
int a2 = Int32.Parse(Console.ReadLine());
Console.Write("b2=");
int b2 = Int32.Parse(Console.ReadLine());
Console.Write("c2=");
int c2 = Int32.Parse(Console.ReadLine());
if ((a1 == 0 && b1 == 0 && c1 == 0) || (a2 == 0 && b2 == 0 && c2 == 0))
{
Console.WriteLine("He phuong trinh vo so nghiem");
break;
}
else
if ((a1 == 0 && b1 == 0) || (a2 == 0 && b2 == 0))
{
Console.WriteLine("He phuong trinh vo nghiem");
break;
}
int t1, t2, t3;
t1 = (-a2) * a1;
t2 =-b2 * a1;
t3 = (-c2) * a1;
a2 = a2 * a1;
b2 = b2 * a1;
c2 = c2 * a1;
a1 = a1 + a2;
b1 = b1 + b2;
c1 = c1 + c2;
float y = (c1 - a1) / b1;
float x = (c2 - b2 * y) / a2;
Console.WriteLine("Ta co x={0} va y={1}",x,y);
*/


/*Câu 5/3
Console.Write("Ban muon choi 1 nguoi hay 2 nguoi:\n1 nguoi\n2 nguoi\nNoi le len coi,1 hay 2:");
int k = Int32.Parse(Console.ReadLine());
Console.Clear();
if (k == 1)
{
Console.Write("Ban hay chon 1 trong 3 so tương ung:\n1.Keo\n2.Bua\n3.Bao\nCon so nao day,con so nao day,do la con so:");
int a = Int32.Parse(Console.ReadLine());
Random b = new Random();
int c = b.Next(1, 4);
string d = "";
if (c == 1)
d = "Keo";
if (c == 2)
d = "Bua";
if (c == 3)
d = "Bao";
Console.WriteLine("May ra " + d);
if (a == c)
Console.WriteLine("Hue");
else
if ((a == 1 && c == 2) || (a == 2 && c == 3) || (a == 3 && c == 1))
Console.WriteLine("Cai may khon nan da thang");
else
Console.WriteLine("Xin chuc mung ban da win");
}
else
if (k == 2)
{
Console.Write("Ban hay chon 1 trong 3 so tương ung:\n1.Keo\n2.Bua\n3.Bao\nCon so nao day,con so nao day,do la con so:\nNguoi1:");
int a = Int32.Parse(Console.ReadLine());
Console.Clear();
Console.Write("Nguoi 2:");
int c = Int32.Parse(Console.ReadLine());
Console.Clear();
string d="",g = "";
if (c == 1)
d = "Keo";
if (c == 2)
d = "Bua";
if (c == 3)
d = "Bao";
if (a == 1)
g = "Keo";
if (a == 2)
g = "Bua";
if (a == 3)
g = "Bao";
Console.WriteLine("Nguoi 1 ra {0} Nguoi 2 ra {1} ", g,d);
if (a == c)
Console.WriteLine("Hue");
else
if ((a == 1 && c == 2) || (a == 2 && c == 3) || (a == 3 && c == 1))
Console.WriteLine("Vay nguoi choi 1 thang");
else
Console.WriteLine("Vay nguoi choi 2 thang");
}
else
Console.Write("Chon sai roi thang kia,chon lai di");
*/

/*Câu 6/3
Console.Write("Nhap so:\na=");
int a = Int32.Parse(Console.ReadLine());
Console.Write("b=");
int b = Int32.Parse(Console.ReadLine());
Console.Write("c=");
int c = Int32.Parse(Console.ReadLine());
Console.Write("d=");
int d = Int32.Parse(Console.ReadLine());
Console.WriteLine("So lon nhat la {0} va so nho nhat la {1}", Math.Max(Math.Max(a, b), Math.Max(c, d)), Math.Min(Math.Min(a, b), Math.Min(c, d)));
*/



/*Cau tinh dien tich hinh vanh khan///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int a, b,c;
double dt;
c = a=0;
Console.WriteLine(a +" "+ c);
do
{
Console.Write("Nhap hai ban kinh cua hinh vanh khan:\na=");
a = Int32.Parse(Console.ReadLine());
Console.Write("b=");
b = Int32.Parse(Console.ReadLine());
if (a <= 0 || b <= 0)
Console.WriteLine("Ban phai nhap so duong");
if (a == b)
Console.WriteLine("Day khong phai hinh vanh khan");
} while (a <= 0 || b <= 0||a==b);
dt = Math.Round(Math.PI * (Math.Abs(a * a - b * b))*100)/100;
double dta = Math.PI * a * a;
double dtb = Math.PI * b * b;
double dth =Math.Round( Math.Abs(dta - dtb)*100)/100;
c = a + b;
Console.WriteLine("dt vanh khan la {0}\ndien tich a la{1}\ndien tich b la {2}\ndien tich vanh khan{3}",dt,dta,dtb,dth);
*//////////////////////////////////////////////////////////////////////////////////////////////////


/*///////////////////////////////////////////////////////////////Cau 13/3
int d, m, y;
int th;
do
{
Console.Write("Nhap ngay/thang/nam \nNgay:");
d = Int32.Parse(Console.ReadLine());
Console.Write("Thang:");
m = Int32.Parse(Console.ReadLine());
Console.Write("Nam:");
y = Int32.Parse(Console.ReadLine());
if (d <= 0 || m <= 0 || y <= 0)
Console.WriteLine("Ban phai nhap so duong khac '0'");

} while (d <= 0 || m <= 0 || y <= 0);
if (m < 3)
{
m = m + 12;
y = y - 1;
}
th = Math.Abs(d + 2 * m + 3 * (m + 1) / 5 + y + y / 4) % 7;
switch(th)
{
case 0:
Console.WriteLine("Ngay do la Chu Nhat");
break;
case (1):
Console.WriteLine("Ngay do la thu Hai");
break;
case (2):
Console.WriteLine("Ngay do la thu Ba");
break;
case (3):
Console.WriteLine("Ngay do la thu Tu");
break;
case (4):
Console.WriteLine("Ngay do la thu Nam");
break;
case (5):
Console.WriteLine("Ngay do la thu Sau");
break;
case (6):
Console.WriteLine("Ngay do la thu Bay");
break;

}
*/////////////////////////////////////////////////////////////////////////



/*////////////////////////////////////////////////////////////////Cau 16/3
Console.Write("Nhap nam sinh cua ban :");
int nam = Int32.Parse(Console.ReadLine());
int can = 0;
int chi = 0;
can = nam % 10;
chi = nam % 12;
Console.Write("Day la nam :");
switch (can)
{
case 0 :
Console.Write("Canh");
break;
case 1:
Console.Write("Tan");
break;
case 2:
Console.Write("Nham");
break;
case 3:
Console.Write("Quy");
break;
case 4:
Console.Write("Giap");
break;
case 5:
Console.Write("At");
break;
case 6:
Console.Write("Binh");
break;
case 7:
Console.Write("Dinh");
break;
case 8:
Console.Write("Mau");
break;
case 9:
Console.Write("Ky");
break;
}
Console.Write(" ");

switch (chi)
{
case 0:
Console.Write("Than");
break;
case 1:
Console.Write("Dau");
break;
case 2:
Console.Write("Tuat");
break;
case 3:
Console.Write("Hoi");
break;
case 4:
Console.Write("Ti");
break;
case 5:
Console.Write("Suu");
break;
case 6:
Console.Write("Dan");
break;
case 7:
Console.Write("Meo");
break;
case 8:
Console.Write("Thin");
break;
case 9:
Console.Write("Ty");
break;
case 10:
Console.Write("Ngo");
break;
case 11:
Console.Write("Mui");
break;
}
*/////////////////////////////////////////////////////////////////////////////////////

/*////////////////////////////////////////////////////////////Cau 17/3
Console.Write("Nhap nam sinh cua 2 ban \nNam:");
int nam = Int32.Parse(Console.ReadLine());
Console.Write("Nu:");
int nu = Int32.Parse(Console.ReadLine());
int china = 0;
int chinu = 0;
china = nam % 12;
chinu = nu % 12;
Console.Write("Day la nam sinh cua 2 ban:\nNam sinh nam ");
switch (china)
{
case 0:
Console.Write("Than");
break;
case 1:
Console.Write("Dau");
break;
case 2:
Console.Write("Tuat");
break;
case 3:
Console.Write("Hoi");
break;
case 4:
Console.Write("Ti");
break;
case 5:
Console.Write("Suu");
break;
case 6:
Console.Write("Dan");
break;
case 7:
Console.Write("Meo");
break;
case 8:
Console.Write("Thin");
break;
case 9:
Console.Write("Ty");
break;
case 10:
Console.Write("Ngo");
break;
case 11:
Console.Write("Mui");
break;
}

Console.Write("\nNu sinh nam ");
switch (chinu)
{
case 0:
Console.Write("Than");
break;
case 1:
Console.Write("Dau");
break;
case 2:
Console.Write("Tuat");
break;
case 3:
Console.Write("Hoi");
break;
case 4:
Console.Write("Ti");
break;
case 5:
Console.Write("Suu");
break;
case 6:
Console.Write("Dan");
break;
case 7:
Console.Write("Meo");
break;
case 8:
Console.Write("Thin");
break;
case 9:
Console.Write("Ty");
break;
case 10:
Console.Write("Ngo");
break;
case 11:
Console.Write("Mui");
break;
}
if (Math.Abs(china - chinu)%3 == 0)
Console.WriteLine("\nTuoi hai ban xung khac nhau");
else
Console.WriteLine("Hai bạn khong khac tuoi");

*////////////////////////////////////////////////////////

/*////////////////////////////////////////////////////////Cau 18/3
///////A
* Console.Write("Nhap N=");
int n = Int32.Parse(Console.ReadLine());
int s = 1;
Console.Write("S=1");
for (int i = 2; i < n + 1; i++)
{
s = s + i;
Console.Write("+"+ i);
}
Console.WriteLine("\nTa co S="+s);
///////A
*
* /////////////////////////////////////B
Console.Write("Nhap N=");
int n = Int32.Parse(Console.ReadLine());
float s = 1;
Console.Write("S=1");
for (int i = 2; i < n + 1; i++)
{
s = s + 1 / (float)i;
Console.Write("+ 1/" + i);
}
Console.WriteLine("\nTa co S=" + s);
* ///////////////////////////////////////B
* ///////////////////////////////////////C
Console.Write("Nhap N=");
int n = Int32.Parse(Console.ReadLine());
float s = 1;
Console.Write("S=1");
for (int i = 2; i < n + 1; i++)
{
s = s + 10*i+i;
Console.Write("+ " + i+i);
}
Console.WriteLine("\nTa co S=" + s);
* ////////////////////////////////////////c
* ///////////////////////////////////////D
Console.Write("Nhap N=");
int n = Int32.Parse(Console.ReadLine());
float s = 1;
Console.Write("S=1");
for (int i = 2; i < n + 1; i++)
{
s = s *i;
Console.Write("* " + i);
}
Console.WriteLine("\nTa co S=" + s);
* //////////////////////////////////////////D
///////////////////////////////////////////C
Console.Write("Nhap N=");
int n = Int32.Parse(Console.ReadLine());
float s = 1;
float a ;
Console.Write("S=1 ");
for (int i = 2; i < n + 1; i++)
{
a = 1;
for(int j=1;j a= a * j;
Console.Write(a+" ");
s=s+1/a;
http://Console.Write("+ 1/ " + i+"!");
}
Console.WriteLine("\nTa co S=" + s);
*////////////////////////////////////////////C

/*//////////////////////////////////////////D
Console.Write("Nhap N=");
int n = Int32.Parse(Console.ReadLine());
float s = 1/2f;

Console.Write("S=1/2 "+s);
for (int i = 2; i < n + 1; i++)
{

s =s+ (float)1/(i*(i+1));
http://Console.Write(s + " ");

Console.Write("+ 1/(" + i+"*"+(i+1)+")");
}
Console.WriteLine("\nTa co S=" + s);
*//////////////////////////////////////////

/*//////////////////////////Cau 20/4
Console.Write("Nhap N=");
int n = Int32.Parse(Console.ReadLine());
int b=1;
float a=(float)Math.Sqrt(n);
for(int i=2;i<=a;i++)
{
if (n % i == 0)
{
b = 0; break;

}

}if(b==0)
Console.WriteLine("Khong phai NT");
else
Console.WriteLine("LA NT");
*//////////////////////////////////////////


/*////////////////////////////////////////////Cau 48/5
Console.Write("Nhap N=");
int n = Int32.Parse(Console.ReadLine());
int t50 = 0, t20 = 0, t10 = 0, t5 = 0, t1 = 0;
for (t50 = 0; t50 <= n / 50; t50++)
for (t20 = 0; t20 <= n / 20; t20++)
for (t10 = 0; t10 <= n / 10; t10++)
for (t5 = 0; t5 <= n / 5; t5++)
for (t1 = 0; t1 <= n / 1; t1++)
if(t50*50+t20*20+t10*10+t5*5+t1 ==n)
Console.WriteLine("{0} to 50 dong,{1} to 20 dong,{2} to 10 dong,{3} to 5 dong,{4} to 1 dong", t50, t20, t10, t5, t1);

Console.WriteLine("Gia tri nhi phan cua N la:" );
*///////////////////////////////////////////////


/*/////////////////////////////////////////////Cau 23
Console.Write("Nhap N=");
int n = Int32.Parse(Console.ReadLine());
Console.Write("Nhap x=");
int x = Int32.Parse(Console.ReadLine());
double f = 0;
for (int i = n; i >= 1; i--)
{
Console.Write("Nhap a{0}=",i);
int a = Int32.Parse(Console.ReadLine());
f = (f + a) * x;
Console.WriteLine(f);
}
Console.Write("Nhap a0=");
int b = Int32.Parse(Console.ReadLine());
f = f + b;
Console.WriteLine("Ta tinh dc F=" + f);
*//////////////////////////////////////////////


/*/////////////////////////////////////////////Cau 24
Console.Write("Nhap N=");
int n = Int32.Parse(Console.ReadLine());
for (int g = 2;n>0; g++)
{
int j = 2;
while (g % j != 0)
j++;
if (j == g)
{
n--;
Console.WriteLine(g);
}
}

*///////////////////////////////////////////////

/*/////////////////////////////////////////////Cau 25/4
Console.WriteLine("Nhap chuoi:");
string a = Console.ReadLine();
Console.Clear();
Console.Write(a);
for(int i=0;i<81-a.Length;i++)
{
Console.SetCursorPosition(i,1);
Console.Write(a);
System.Threading.Thread.Sleep(100); Console.Clear();
}
*////////////////////////////////////////////////


/*///////////////////////////////////////////////Cau 26
Console.Write("Nhap dai=");
int d = Int32.Parse(Console.ReadLine());
Console.Write("Nhap rong=");
int r = Int32.Parse(Console.ReadLine());
Console.Clear();
for (int i = 0; i < r; i++)
{
for (int j = 0; j < d; j++)
{
if (i == 0 || i == r - 1)
Console.Write('*');
else
if(j==0||j==d-1)
Console.Write('*');
else
Console.Write(' ');
}
Console.Write("\n");
}
*////////////////////////////////////////////////


/*///////////////////////////////////////////////Cau 27/4
Console.Write("Nhap dai=");
int d = Int32.Parse(Console.ReadLine());
Console.Write("Nhap rong=");
int r = Int32.Parse(Console.ReadLine());
Console.Clear();
int a = 0, b = 0;
inhcm(d, r,a,b);
while(true)
{
ConsoleKeyInfo c=Console.ReadKey();
if (c.Key == ConsoleKey.LeftArrow && a > 0)
a--;
if (c.Key == ConsoleKey.RightArrow && a < 80-d)
a++;
if (c.Key == ConsoleKey.DownArrow)
b++;
if (c.Key == ConsoleKey.UpArrow &&b > 0)
b--;
if (c.Key == ConsoleKey.PageUp)
{
d++;
r++;
}
if (c.Key == ConsoleKey.PageDown)
{
d--;
r--;
}
Console.Clear();
inhcm(d, r,a,b);
}
* *///////////////////////////////////////////////////


/*/////////////////////////////////////////////Cau 36
Console.Write("Nhap n=");
int n = Int32.Parse(Console.ReadLine());
for (int i = 0; i <= n; i++)
{
Console.WriteLine();
for (int j = 0; j <= i; j++)
Console.Write(tohop(i, j) + " ");
}
*////////////////////////////////////////////////////

/*/////////////////////////////////////////////////Cau 39/4
Console.Write("Nhap tien gui la:");
int g = Int32.Parse(Console.ReadLine());
Console.Write("Nhap so thang gui la:");
int t= Int32.Parse(Console.ReadLine());
Console.Write("Nhap % lai suat tung thang la:");
int s = Int32.Parse(Console.ReadLine());
for (int i = 0; i < t; i++)
{
g = g + g * s / 100;
}
Console.Write("So lien lanh la:{0}VND", g);
*///////////////////////////////////////////////////
/*//////////////////////////////////////////////////Cau 40
Console.Write("Nhap n=");
int n = Int32.Parse(Console.ReadLine());
Console.Write("Nhap m=");
int m = Int32.Parse(Console.ReadLine());
int uocsoln = 0,boisonn=0;
int a =Math.Max(n, m),b=Math.Min(n,m);
while (Math.Abs(m-n)!=0 )
{
uocsoln = Math.Abs(m - n);
if(Math.Abs(m)>=Math.Abs(n))
m = uocsoln;
else
n=uocsoln;
}
//Cach 1:boisonn = a * b / uocsoln;
//Cach 2:
int c = 1;
int i = 1;

do
{
c = a * i;
i++;
} while (c % b != 0 && c < a * b);
boisonn = c;
//Het cach hai boi so chung nho nhat
Console.WriteLine("Uoc so chung lon nhat la:" + uocsoln);
Console.WriteLine("Boi so chung nho nhat la:" + boisonn);
*///////////////////////////////////////////////////////

/*//////////////////////////////////////////////////////Cau 41/4
Console.WriteLine("Ban hay doan 1 so tu 0 toi 101 trong 10 lan:");
Random r = new Random();
int a = r.Next(101),i=0;
Console.Write(a);
while (i < 10)
{
Console.Write("n=");
int n = Int32.Parse(Console.ReadLine());
if (n == a)
{
Console.WriteLine("So ban doan dung roi");
break;
}
if (n > a)
Console.WriteLine("So ban doan lon hon so dc chon");
if (n < a)
Console.WriteLine("So ban doan nho hon so dc chon");
i++;
}
///*/////////////////////////////////////////////////////////

/*//////////////////////////////////////////////////////////Cau 43
Console.Write("Nhap mot chuoi cho roi s=");
string s = Console.ReadLine(); int i = 0;
Console.SetBufferSize(80,30);
while (i {
Console.Clear();
Console.SetCursorPosition(0, i);

Console.WriteLine(s);
System.Threading.Thread.Sleep(100);
i++;
}
*///////////////////////////////////////////////////////////

//0902513292 thu ke toan
/*/////////////////////////////////////////////////////////Cau 45/5
Console.Write("Nhap n=");
int n = Int32.Parse(Console.ReadLine());
int dem = 0,tong=0;
while (true)
{

tong = tong+n % 10;
dem++;
n = n / 10;
if (n / 10 == 0)
{
tong = tong + n ;
dem++;
break;
}
}
Console.WriteLine("So ki so la {0} ki so,va tong cac ki so do la {1}", dem, tong);
*////////////////////////////////////////////////////////////

/*///////////////////////////////////////////////////////////Cau 46/5
Console.Write("Nhap n=");
int n = Int32.Parse(Console.ReadLine());
int tmp = 0;
int a = n;
while (true)
{
tmp = tmp*10 + n % 10;
n = n / 10;
if (n / 10 == 0)
{
tmp = tmp * 10 + n % 10;
break;
}
}
if (tmp == a)
Console.WriteLine("So nay doi xung");
else
Console.WriteLine("So nay k doi xung");
*////////////////////////////////////////////////////////////

/*//////////////////////////////////////////////////////////Cau 47
Console.Write("Nhap n=");
int n = Int32.Parse(Console.ReadLine());
Console.Write("Nhap m=");
int m = Int32.Parse(Console.ReadLine());
int tmp = 0;
int a = n;
for (int i = 0; i < m; i++)
{
tmp = tmp + n % 10;
n = n / 10;
}
Console.WriteLine("Tong {0} ky so cuoi cua {1} la {2}", m, a, tmp);
*/////////////////////////////////////////////////////////////

/*////////////////////////////////////////////////////////////Cau 50
Console.Write("Nhap n=");
int n = Int32.Parse(Console.ReadLine());
int tmp = 0;
int a = n;
while (true)
{
tmp = tmp * 10 + n % 10;
n = n / 10;
if (n / 10 == 0)
{
tmp = tmp * 10 + n % 10;
break;
}
}
Console.WriteLine("So N' la {0}", tmp);
*//////////////////////////////////////////////////////////////////

/*////////////////////////////////////////////////////////////////////////////////Câu 7/5
Console.Write("Nhap n=");
int n = Int32.Parse(Console.ReadLine()),x=0;
string[] t = new string[n+1];
string[] cmnd = new string[n+1];
string[] ngay = new string[n+1];
Console.WriteLine("Ban hay nhap ho ten cua khach theo so thu tu:");
nhapmang(t, n);
Console.WriteLine("Ban hay nhap so cmdn cua khach theo so thu tu:");
nhapmang(cmnd, n);
Console.WriteLine("Ban hay nhap ngay thue cua khach theo so thu tu:");
nhapmang(ngay, n);
Console.WriteLine("Chọn chuc nang mà bạn muon dung,chon 1 hoac 2:\n1.Nhap CMND tim khach hang\n2.Nhap X>0 va X int f = Int32.Parse(Console.ReadLine());
if (f == 1)
{
Console.Write("CMDN:");
string a = Console.ReadLine();
for (int i = 1; i <=n; i++)
if (a == cmnd[i])
Console.Write("{0} thuê tro phong {1} vao ngay {2}", t[i], i, ngay[i]);
}
else
{
do
{
Console.Write("X=");
x = Int32.Parse(Console.ReadLine());
} while (x <= 0 || x >= n);
Console.Write("Khach {0} cmnd:{1} thuê tro phong {2} vao ngay {3}", t[x],cmnd[x], x, ngay[x]);
}
*///////////////////////////////////////////////////////////////////////////////////////////////

/*********************************************************************************************Cau 8/5
Console.Write("Nhap m=");
int m = Int32.Parse(Console.ReadLine());
Console.Write("Nhap n=");
int n = Int32.Parse(Console.ReadLine());
int j=0,i=0,vtj=0,vti=0,max=0;
int[,] a = new int[m,n];
nhapmatran(a, m, n);

for(i=0;i for (j = 0; j < n; j++)
{
if (a[i, j] > max)
{
max = a[i, j];
vti = i;
vtj = j;
}

}
Console.WriteLine("So lon nhat tai vi tri a[" + vti + "," + vtj + "]=" + max);

*//////////////////////////////////////////////////////////////////////////////////

/***********************************************************************Câu 9/5
Console.Write("Nhap n=");
int n = Int32.Parse(Console.ReadLine()), f = 1;
int [,]a=new int[n,n];
nhapmatran(a, n, n);
for(int i=0;i for (int j = 0; j < n; j++)
if (a[i, j] != a[j, i])
{
f = 0;
break;
}
if (f == 0)
{
Console.WriteLine("Ma tran khong doi xung");
}else
Console.WriteLine("Ma tran doi xung");
*//////////////////////////////////////////////////////////////////////////

/**************************************************************Câu 10/5
Console.Write("Nhap n=");
int n = Int32.Parse(Console.ReadLine()), f = 0;
int[,] a = new int[n, n];
nhapmatran(a, n, n);
xuatmatran(a, n, n);
for (int i = 0; i < n; i++)
for (int j = 0; j < i; j++)
{
f = a[j, i];
a[j, i] = a[i, j];
a[i, j]= f;
}
Console.WriteLine("Ma tran chuyen vi cua a la:");
//xuatmatran(a, n, n);
xuatmatran(a, n, n);
*/////////////////////////////////////////////////////////////////

/*********************************************Cau 11
Console.Write("Nhap n=");
int n = Int32.Parse(Console.ReadLine()), f = 0;
int[,] a = new int[n, n];
int[,] b = new int[n, n];
int[,] c = new int[n, n];
Console.WriteLine("Ma tran A:");
nhapmatran(a, n, n);
xuatmatran(a, n, n);
Console.WriteLine("Ma tran B:");
nhapmatran(b, n, n);
xuatmatran(b, n, n);
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
{
c[i, j] = a[i, j] + b[i, j];
}
Console.WriteLine("Ma tran C:");
xuatmatran(c, n, n);
*//////////////////////////////////////////////////////////////

//*************************************************************Câu 12/5
Console.Write("Nhap m=");
int m = Int32.Parse(Console.ReadLine());
Console.Write("Nhap n=");
int n = Int32.Parse(Console.ReadLine());
Console.Write("Nhap p=");
int p = Int32.Parse(Console.ReadLine());
int[,] a = new int[m, n];
int[,] b = new int[n, p];
int[,] c = new int[m, p];
Console.WriteLine("Ma tran A:");
nhapmatran(a, m, n);
xuatmatran(a, m, n);
Console.WriteLine("Ma tran B:");
nhapmatran(b, n, p);
xuatmatran(b, n, p);
for (int i = 0; i < m; i++)
for (int k = 0; k < p; k++)

for(int j=0;j {
c[i, k] = a[i, j] * b[j, k]+c[i,k];
}
Console.WriteLine("Ma tran C:");
xuatmatran(c, m, p);
//*//////////////////////////////////////////////////////////////

Console.Write("\nCo lam tiep khong y/n: ");
char z=char.Parse(Console.ReadLine());
if (z != 'y')
break;
}while(true);
Console.ReadLine();
}
/////////////////////////////////////Cau 36
static long giaithua(int n)
{
long a = 1;
for (int i = 1; i <= n; i++)
a = a * i;
return a;
}
static long tohop(int n, int k)
{
long to = 1;
to = giaithua(n) / (giaithua(k) * giaithua(n - k));
return to;
}
//////////////////////////////////////Cau 36
static void nhapmang(string[] a, int n)
{
for (int i = 1; i <= n; i++)
{
Console.Write("{0}.", i);
a[i] = Console.ReadLine();
}
}
static void xuatmang(string[] a, int n)
{
for (int i = 1; i <=n; i++)
Console.WriteLine("{0}.{1)", i,a[i]);
}
static void nhapmatran(int[,] a, int m, int n)
{
for(int i=0;i for (int j = 0; j < n; j++)
{
Console.Write("a["+i+","+j+"]=");
a[i,j] = Int32.Parse(Console.ReadLine());
}
}
static void xuatmatran(int[,] a, int m, int n)
{
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
Console.Write(a[i, j] + " ");
Console.WriteLine();
}
}
}
}
liongak
liongak
Cống hiến
Cống hiến

Tổng số bài gửi : 202
Join date : 16/09/2009
Age : 37
Đến từ : Thanh Hóa

Về Đầu Trang Go down

Một số bài ôn tập C# của lớp luyện thi đầu vào Empty Re: Một số bài ôn tập C# của lớp luyện thi đầu vào

Bài gửi by liongak 7/1/2010, 23:38

Phần 2:
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static double giaithua(double n)
{
double ng=1;
for (int i = 1; i < n + 1; i++)
ng = ng * i;
return ng;
}
static void Main(string[] args)
{
do
{
/* Câu 4
* Console.WriteLine("Nhap ho ten: ");
string t = Console.ReadLine();
Console.WriteLine("Chi so dien ke cu: ");
int c=Int32.Parse(Console.ReadLine());
Console.WriteLine("Chi so dien ke moi: ");
int m=Int32.Parse(Console.ReadLine());
int h=m-c;
float tieu=h*452.45f;
Console.Clear();
Console.Write("-------------------------------");
Console.SetCursorPosition(4, 2);
Console.WriteLine("Khach hang: " + t+"\nChi so cu: "+c+"\nChi so moi: "+m+"\nTieu thu: "+h+"\nTien dien: "+tieu+"\n");
Console.SetCursorPosition(4, 9);
Console.WriteLine("Yeu cau tiet kiem\n-------------------------------");
*/

/*Câu 8
* Console.Write("Nhap ban kinh: ");
int r = Int32.Parse(Console.ReadLine());
double c = 2 * r * Math.PI;
double d = Math.Pow(r, 2) * Math.PI;
Console.WriteLine("Chu vi cua no là: "+c+"\ndien tich: "+d);
*/
/*Câu 9
Console.Write("Nhap ho1: ");
string h1 = Console.ReadLine();
Console.Write("Nhap ten1: ");
string t1 = Console.ReadLine();
Console.Write("Nhap ho2: ");
string h2 = Console.ReadLine();
Console.Write("Nhap ten2: ");
string t2 = Console.ReadLine();
Console.Clear();
Console.SetCursorPosition(9,1);
Console.Write("Than goi " + h1 + ' ' + t1);
Console.SetCursorPosition(8, 2);
Console.Write("Nhan dip sinh nhat cua " + t1 + ", cho phep " + t2 + " goi den " + t1 + " nhung loi chuc tot dep nhat ve suc khoe , hanh phuc va thanh cong trong moi lanh vuc.");
Console.SetCursorPosition(8, 4);
Console.Write("Goi loi tham suc khoe hai bac cua " + t1 + ".");
Console.SetCursorPosition(39, 5);
Console.Write("Ban cua " + t1);
Console.SetCursorPosition(39, 6);
Console.Write(h2+" "+t2);
Console.SetCursorPosition(8, 7);
Console.Write("TB: Ba ma "+t2+" thuong nhac den "+t1+" luon\n");
*/

/*Câu 10
Console.Write("Nhap tien gui: ");
int t=Int32.Parse( Console.ReadLine());
float ti = t;
Console.Write("Nhap lai suat %: ");
float l =Single.Parse( Console.ReadLine());
Console.Write("Nhap thang: ");
int th = Int32.Parse(Console.ReadLine());
float la = t * l / 100;
for (int i = 1; i <= th; i++)
{
ti = ti + la;
}
Console.Write("tien lai hang thang la {0} va tien no nhan sau {1} la {2}\n", la, th, ti);
*/

/*câu13
Console.WriteLine("Nhap ho ten khach hang: ");
string t = Console.ReadLine();
Console.WriteLine("Nhap so ngay o: ");
int ngay = Int32.Parse(Console.ReadLine());
Console.WriteLine("Nhap so bua an: ");
int an = Int32.Parse(Console.ReadLine());
Console.WriteLine("Gia phong: ");
int giaphong = Int32.Parse(Console.ReadLine());
Console.WriteLine("Gia 1 bua an: ");
int giaan = Int32.Parse(Console.ReadLine());
Console.WriteLine("Phi phuc vu 1 ngay: ");
int phi = Int32.Parse(Console.ReadLine());
int tieno = ngay*giaphong;
int tienan = an * giaan;
int tienphi = phi * ngay;
int tong = tieno + tienan + tienphi;

Console.Clear();
Console.Write("***************************************");
Console.SetCursorPosition(6, 2);
Console.WriteLine("Khach san LiongAK " );
Console.SetCursorPosition(6,3);
Console.WriteLine("Hoa don Khach San");
Console.SetCursorPosition(3,4);
Console.WriteLine("Quy Ong(Ba): "+t);
Console.SetCursorPosition(3,5);
Console.WriteLine("So ngay o: "+ngay+"\tSo bua an: "+an);
Console.SetCursorPosition(3,6);
Console.WriteLine("Tien o:{0}VND Tien an: {1}VND Phi phuc vu: {2}VND",tieno,tienan,tienphi);
Console.SetCursorPosition(3, 7);
Console.WriteLine("Tong Cong: "+tong);
Console.SetCursorPosition(20,Cool;
Console.WriteLine("Han hanh phuc vu quy khach\n***************************************");
*/

/*Câu 14
Console.WriteLine("Nhap X: ");
double x = Double.Parse(Console.ReadLine());
Console.SetCursorPosition(10, 1);

Console.WriteLine("Bang ke so tu {0} den {1}\nN\tN*N\t\t1/N\t\tCan bac 2\t\tCan bac 4\n", x, x + 5);
for (int i = 0; i < 6; i++)
{
double t = Math.Sqrt(x);
Console.Write("{0}\t{1}\t\t{2}\t\t{3}\t\t\t{4}\n", x, x * x, Math.Round(1 / x * 100) / 100, Math.Round(Math.Sqrt(x) * 100) / 100, Math.Round(Math.Sqrt(t) * 100) / 100);
x++;
}
*/

/* DO 523.25 DO # 554.37
RE 587.33 RE # 622.25
MI 659.26
FA 698.46 FA # 739.99
SOL 783.99 SOL# 830.61
LA 880 LA # 932.33
SI 987.77
*/

/*Cau15
int DO =523;
int DO1=554;
int RE =587;
int RE1=622;
int MI =659;
int FA =98;
int FA1=740;
int SOL=783;
int SOL1=830;
int LA =880;
int LA1=932;
int SI =988;
Console.Beep(SOL,500);
Console.Beep(SOL, 500);
Console.Beep(DO1, 600);
Console.Beep(SOL, 500);
Console.Beep(MI,500);
*/

/*Câu 16
Console.Write("Nhap so lon nhot khach hang mua: ");
int n = Int32.Parse(Console.ReadLine());
int non, viet;
int tien = n * 27000;
non = n / 3;
viet = n % 3 * 2;
Console.WriteLine("Tien khach hang phai tra la {0}VND va khach duoc tang {1} cai non va {2} cay viet",tien,non,viet);
*/

/*Câu 1/3
Console.Write("Ta co phuong trinh sau ax^2+bx+c=0 .Nhap:\n a=");
int a=Int32.Parse(Console.ReadLine());
Console.Write(" b=");
int b=Int32.Parse(Console.ReadLine());
Console.Write(" c=");
int c=Int32.Parse(Console.ReadLine());
float denta=(float)Math.Sqrt(b*b-4*a*c);
if (denta == 0)
Console.WriteLine("Phuong trinh co nghiem kep x1=x2=" + (-b / 2 * a));
else
if (denta > 0)
{
float x1 = (-b - denta) / 2 * a;
float x2 = (-b + denta) / 2 * a;
Console.Write("Nghiem cua phuong trinh la x1={0} và x2={1}\n", x1, x2);
}
else
Console.WriteLine("Phuong trinh vo nghiem");
Console.WriteLine(denta);
*/

/*//////////////////////////////////////////////////////////////Câu 2/3
Console.Write("Nhap ten ban vao: ");
string s = Console.ReadLine();
string s1="Thi";
s1=s1.ToUpper();
s=s.ToUpper();
int k =( s.IndexOf(s1));
Console.WriteLine("k={0}\ns={1}\ns1={2}",k,s,s1);
if (k<0)
Console.WriteLine("Ban la Nam");
else
Console.WriteLine("Ban la Nu");
*/



/*
* /////////////////////////////////////////////////////////////Cau 7/3
Console.Write("Nhap a=");
int a = Int32.Parse(Console.ReadLine());

Console.Write("Nhap b=");
int b = Int32.Parse(Console.ReadLine());

Console.Write("Nhap c=");
int c = Int32.Parse(Console.ReadLine());

Console.Write("Nhap d=");
int d = Int32.Parse(Console.ReadLine());
int max1=0;
int max2=0;
int max3=0,max4=0;
max1 = Math.Max(Math.Max(a, b), Math.Max(c, d));
if (max1 == a)
{
max2 = Math.Max(Math.Max(c, b), d);
if (max2 == b)
{
max3 = Math.Max(c, d);
if (max3 == c)
max4 = d;
else
max4 = c;

}
if (max2 == c)
{
max3 = Math.Max(b, d);
if (max3 == b)
max4 = d;
else
max4 = b;
}
if (max2 == d)
{
max3 = Math.Max(b, c);
if (max3 == b)
max4 = c;
else
max4 = b;
}

}

if (max1 == b)
{
max2 = Math.Max(Math.Max(c, a), d);
if (max2 == a)
{
max3 = Math.Max(c, d);
if (max3 == c)
max4 = d;
else
max4 = c;

}
if (max2 == c)
{
max3 = Math.Max(a, d);
if (max3 == a)
max4 = d;
else
max4 = a;
}
if (max2 == d)
{
max3 = Math.Max(a, c);
if (max3 == a)
max4 = c;
else
max4 = a;
}

}

if (max1 == c)
{
max2 = Math.Max(Math.Max(a, b), d);
if (max2 == b)
{
max3 = Math.Max(a, d);
if (max3 == a)
max4 = d;
else
max4 = a;

}
if (max2 == a)
{
max3 = Math.Max(b, d);
if (max3 == b)
max4 = d;
else
max4 = b;
}
if (max2 == d)
{
max3 = Math.Max(b, a);
if (max3 == b)
max4 = a;
else
max4 = b;
}

}

if (max1 == d)
{
max2 = Math.Max(Math.Max(c, b), a);
if (max2 == b)
{
max3 = Math.Max(c, a);
if (max3 == c)
max4 = a;
else
max4 = c;

}
if (max2 == c)
{
max3 = Math.Max(b, a);
if (max3 == b)
max4 = a;
else
max4 = b;
}
if (max2 == a)
{
max3 = Math.Max(b, c);
if (max3 == b)
max4 = c;
else
max4 = b;
}

}
Console.WriteLine("Xep theo thu tu giam dan la {0} {1} {2} {3}" , max1,max2,max3,max4);
*/

/*Cau 7/3(2)/////////////////////////////////////////////////////////////////////////////////
Console.Write("Nhap a=");
int a = Int32.Parse(Console.ReadLine());

Console.Write("Nhap b=");
int b = Int32.Parse(Console.ReadLine());

Console.Write("Nhap c=");
int c = Int32.Parse(Console.ReadLine());

Console.Write("Nhap d=");
int d = Int32.Parse(Console.ReadLine());
int max1 = Math.Max(Math.Max(a,b),Math.Max(c,d));
int max2 = a;
int max3 = a, max4 = Math.Min(Math.Min(a, b), Math.Min(c, d));
//max1 = Math.Max(Math.Max(a, b), Math.Max(c, d));
if (b>max4&&bmax2)
max2 = b;
if (c > max4 && c < max1&&c>max2)
max2 = c;
if (d > max4 && d < max1&&d>max2)
max2 = d;
if (b > max4 && b < max1&&b max3 = b;
if (c > max4 && c < max1 && c < max2)
max3 = c;
if (d > max4 && d < max1 && d < max2)
max3 = d;

Console.WriteLine("Xep theo thu tu giam dan la {0} {1} {2} {3}", max1, max2, max3, max4);
*/


/*//////////////////////////////////////////////////////////////////////////////Cau 8/3
int n;
do
{
Console.Write("Nhap N=");
n = Int32.Parse(Console.ReadLine());
if (n < 0)
Console.WriteLine("N la so nguyen duong,xin nhap lai");
} while (n < 0);
if (n % 2 == 0)
Console.WriteLine("N la so chan");
else
Console.WriteLine("N la so le");
*/


/* ///////////////////////////////////////////////////////////////////////////Cau 9/3
int n;
do
{
Console.Write("Nhap N=");
n = Int32.Parse(Console.ReadLine());
if (n < 0)
Console.WriteLine("N la so nguyen duong,xin nhap lai");
} while (n < 0);
if (n % 3 == 0&&n%5==0)
Console.WriteLine("N la boi so cua 3 va 5");
else
Console.WriteLine("N khong phai la boi so cua 3 va 5");
*/

/*Cau21//////////////////////////////////////////////////////
Console.Write("Nhap N=");
int n = Int32.Parse(Console.ReadLine());
string a = " ";
string b = " ";
int n16 = n;
while (n / 2 != 0)
{
a = n % 2 + a;
n = n / 2;

}
while (n16 / 16 != 0)
{
if(n16%16>9)
switch (n16 % 16)
{
case 10:
b = 'A' + b;
break;
case 11:
b = 'B' + b; break;
case 12:
b = 'C' + b; break;
case 13:
b = 'D' + b; break;
case 14:
b = 'E' + b; break;
case 15:
b = 'F' + b; break;

}
else
b = n16 % 16 + b;
n16 = n16/ 16;
Console.WriteLine("N:" + n + "\n" + b);
}
if (n16 % 16 > 9)
switch (n16 % 16)
{
case 10:
b = 'A' + b;break;
case 11:
b = 'B' + b;break;
case 12:
b = 'C' + b;break;
case 13:
b = 'D' + b;break;
case 14:
b = 'E' + b;break;
case 15:
b = 'F' + b;break;

}
else

b = n16 % 16 + b;
a = n + a;

Console.WriteLine("Gia tri nhi phan cua N la: "+a+"\nGia tri thap luc phan cua N la: "+b);
*//////////////////////////////////////////////////////////////

/*///////////////////////////////////////////////////////Cau 22
Console.Write("Nhap N=");
double N = double.Parse(Console.ReadLine());
Console.Write("Nhap k=");
double k = double.Parse(Console.ReadLine());
double c, a;
double ng = giaithua(N);
double kg = giaithua(k);
double nkg = giaithua(N - k);
c = ng / (kg * nkg);
a = ng / nkg;
Console.WriteLine(ng+"*"+kg+"*"+nkg+"Ta co cong thuc to hop C={0}!/({1}-{2})!{3}! \nvay C={4}\nVa cong thuc chinh hop la A={5}!/({6}-{7})! \nvay A={8}",N,N,k,k,c,N,N,k,a);
*/////////////////////////////////////////////////////////////

/*///////////////////////////////////////////////////////////Cau34
Console.Write("Nhap N=");
double N = double.Parse(Console.ReadLine());
int a = 1, b = 1;
int c=0;
Console.Write("Ta co day Fibonacci sau: 1 1 ");
for (int i = 2; i < N; i++)
{
c = a + b;
a = b;
b = c;
Console.Write(c + " ");
}
Console.Write("\nSo hang thu N la "+ c );
*//////////////////////////////////////////////

/*/////////////////////////////////////////////cau 28/4
double c=0;
double a=double.Parse(Console.ReadLine());

while (true)
{
ConsoleKeyInfo k = Console.ReadKey();
Console.WriteLine();
if (k.Key == ConsoleKey.G)
{
c = 1;
for (int i = 1; i <= a; i++)
c = i * c;
Console.WriteLine("Kq=" + c);
break;

}

double b = double.Parse(Console.ReadLine());
if (k.Key == ConsoleKey.Subtract)
c = a - b;
if (k.Key == ConsoleKey.Add)
c = a + b;
if (k.Key == ConsoleKey.Divide)
c = a / b;
if (k.Key == ConsoleKey.Multiply)
c = a * b;

if (k.Key == ConsoleKey.M)
{
c = Math.Pow(a, b);
}
if (k.Key == ConsoleKey.Z)
for (int i = 0; i < b / 2; i++)
{

c = Math.Sqrt(a);
a = c;
}

Console.WriteLine("kq=" + c);
a = c;
} continue;
*///////////////////////////////////////////


/*/////////////////////////////////////////Cau 29/4
Console.Write("Nhap ten:");
string a = Console.ReadLine();
a = a.TrimEnd();
a = a.TrimStart();
int vt=a.LastIndexOf(' ');
int l=a.Length;
string b = a.Substring(vt+1 , l - vt-1);
a = a.Substring(0, vt );
Console.WriteLine("Ho lot:{0}\nTen:{1}", a, b);
*//////////////////////////////////////////

/*
Random r=new Random();
int a=0;
while (a < 24)
{
a++;
Console.Clear();
Console.SetCursorPosition(0, a);
Console.WriteLine(ConsoleKey.Tab);
System.Threading.Thread.Sleep(90);



}
if (Console.ReadKey().Key == ConsoleKey.Tab)
break;

*/

/*/////////////////////////////////////////////Cau 31/4
Console.WriteLine("Nhap x=");
float x = Single.Parse(Console.ReadLine());
Console.Clear();
Console.Write("Do C");
Console.SetCursorPosition(5,0);
Console.WriteLine("Do F");
for (int i = 1; i < 21; i++)
{

Console.Write(x);
Console.SetCursorPosition(5, i);
Console.WriteLine(x * 1.8 + 32);
x++;
}
*////////////////////////////////////////////////

/*//////////////////////////////////////////////Cau 34/4 và 35/4
Console.WriteLine("Nhap n:");
int n = Int32.Parse(Console.ReadLine());
Console.Write("Ta co day Fibonacci sau:1 1 ");
int a = 1,b=1;int c=0;
for (int i = 2; i < n; i++)
{
c= a + b;
a = b;
b = c;
Console.Write(c + " ");
}
Console.Write("\nSo hang thu N la " + c);
*////////////////////////////////////////////

/*///////////////////////////////////////////Cau 51/5
Console.WriteLine("Nhap chuoi s:");
string s = Console.ReadLine();
string a=s,c="",d="";
int f=1;
for (int i = 1; i <= a.Length/2; i++)
{
f = 1;
for (int j = 0; j {
c = a.Substring(j, i);
d = a.Substring(j + i, i);
if (c != d)
{
f = 0;

break;
}
j = j + i;

System.Threading.Thread.Sleep(100);
}
if (f == 1)
{
Console.WriteLine("Chuoi nay tuan hoan");
break;
}

}
if(f==0)
Console.WriteLine("Chuoi k tuan hoan");
*////////////////////////////////////////////////////////

//Mảng 1 chiều và nhiều chiều

/**************************************************Cau 1/5
Console.Write("Nhap N=");
long n = long.Parse(Console.ReadLine());
Console.WriteLine("Nhap lan luot cac tham so tu a0 toi an:");
long [] a=new long [n+1];
double b = 0;
Console.Write("Nhap X=");
long x = long.Parse(Console.ReadLine());
for (int i = 0; i <= n; i++)
{
Console.Write("a{0}=",i);
a[i] = Int64.Parse(Console.ReadLine());
b = a[i] * Math.Pow(x, i) + b;
}
Console.WriteLine("Ket qua:"+b);
**********************************************/

/*****************************************************************************Cau3/5
Console.Write("Nhap N=");
long n = long.Parse(Console.ReadLine());

long[] a = new long[n];
Console.WriteLine("Nhap lan luot cac tham so tu a0 toi an:");
for (int i = 0; i < n; i++)
{
Console.Write("a{0}=",i);
a[i] = Int64.Parse(Console.ReadLine());
}
long max = a[0], min = a[0];
for (int j = 0; j < n; j++)
{
if (a[j] > max)
max = a[j];
if (a[j] < min)
min = a[j];
}
Console.WriteLine("max={0} va min={1}", max, min);
***********************************************************************/

/******************************************************Cau 4/5
Console.Write("Nhap N=");
int n = int.Parse(Console.ReadLine());
int[] a = new int[n];
nhapmang(a, n);


Console.Write("Nhap X=");

long x = long.Parse(Console.ReadLine());
int f = 0;
for (int i = 0; i < n; i++)
{
if (x == a[i])
{
f = 1;
break;
}

}
if (f == 1)
Console.WriteLine("X thuoc mang a");
else
Console.WriteLine("X khong thuoc mang a");
****************************************************************/

/************************************************Cau 5/5
Console.Write("Nhap N=");
int n = Int32.Parse(Console.ReadLine());
int[] a = new int[n];
nhapmang(a, n);
int tmp=0;
for (int i = 0; i < n-1; i++)
for (int j = i+1; j < n; j++)
if (a[i] > a[j])
{
tmp = a[i];
a[i] = a[j];
a[j] = tmp;
}
xuatmang(a,n);
*****************************************************************************/

/*************************************************************Cau 6/5
Console.WriteLine("Nhap chuoi s:");
string s=Console.ReadLine();
char[] a = new char[s.Length];
for (int i = 0; i < s.Length; i++)
{
a[i] = s[i];
int b = Convert.ToInt32(a[i]);
if(b>96&&b<123)
b=b-32;
a[i] = Convert.ToChar(b);
}


Console.WriteLine(a);
*//////////////////////////////////////////////////////////////////////

/*****************************************************Cau 13/5
Console.Write("Nhap N:");
int n = Int32.Parse(Console.ReadLine());
int [] a=new int [n];
nhapmang(a, n);
int demam = 0, demduong = 0,tongam=0,tongduong=0;
for (int i = 0; i < n; i++)
{
if (a[i] >= 0)
{
demduong++;
tongduong = tongduong + a[i];
}
else
{
demam++;
tongam = tongam + a[i];
}
}
Console.WriteLine("Ta co {0} so am,{1} so duong,tong so am la {2} va tong so duong la {3}", demam, demduong, tongam, tongduong);
*//////////////////////////////////////////////////////////////////////////

/*********************************************************Cau 14/5
Console.Write("Nhap N:");
int n = Int32.Parse(Console.ReadLine());
int[] a = new int[n];
nhapmang(a, n);
Console.Write("Nhap X:");
int x = Int32.Parse(Console.ReadLine());
Console.WriteLine("Cac vi tri co X trong mang la");
for (int i = 0; i < n; i++)
if (a[i] == x)
Console.Write(i+" ");
*//////////////////////////////////////////////////////////////////////////

/******************************************Cau16/5
Console.WriteLine("Nhap te le di ba con");
string []s=new string[100];
int i = 0,vt=0,max=0;
while (true)
{
i++;
s[i] = Console.ReadLine();


if (s[i].Length > max)
{
max = s[i].Length;
vt = i;
}
if (s[i].Length > 2)
if (s[i].Substring(s[i].Length - 3, 3) == "END")
break;

}
Console.WriteLine("ban da nhap {0} dong,dong dai nhat la dong thu {1} va no co {2} tu",i,vt,max);
*////////////////////////////////////////////////////////////////////////

/****************************************************Cau 17/6
Console.Write("Nhap N:");
int n = Int32.Parse(Console.ReadLine());
double[,] a = new double[n,n];
for (int i = 0; i < n;i++ )
{Console.WriteLine();
for (int j = 0; j <=i; j++)
{
a[i,j]=giaithua(i)/(giaithua(j)*giaithua(i-j));
Console.Write(a[i,j]+" ");
}
}
*//////////////////////////////////////////////////////////////////

/*********************************************Cau 18/6
Console.Write("Nhap N:");
int n = Int32.Parse(Console.ReadLine());
int [] a = new int[n];
a[0]=a[1]=1;
Console.Write("1 1 ");
for (int i = 2; i < n; i++)
{
a[i] =a[i-2]+ a[i - 1];
Console.Write("{0} ",a[i]);
}
*//////////////////////////////////////////////////////////////

/****************************************Cau 20
int n=0;
do
{
Console.Write("Nhap tháng N:");
n = Int32.Parse(Console.ReadLine());
} while (n < 1 || n > 12);
int[] a = new int[13];
for (int i = 1; i <= 12; i++)
{
if (i == 2)
a[i] = 28;
else
if (i < Cool
if (i % 2 == 0)
a[i] = 30;
else
a[i] = 31;
else
if (i % 2 == 0)
a[i] = 31;
else
a[i] = 30;
}
Console.WriteLine("Thang {0} co {1} ngay", n, a[n]);
*///////////////////////////////////////////////////

int n;
do
{
Console.WriteLine("Nhap N tu 1 toi 10");
n = Int32.Parse(Console.ReadLine());
} while (n < 1 || n > 10);
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= i; j++)
{
if (j == 1 || j == i||i==n)
Console.Write("x");
else
Console.Write(" ");
}
Console.WriteLine();

}












Console.Write("\nCo muon lam nua khong y/n:");
char y = char.Parse(Console.ReadLine());
if (y != 'y')
break;
} while (true);
}
static void nhapmang(int[] a, int n)
{
for (int i = 0; i < n; i++)
{
Console.Write("a{0}=", i);
a[i] = Int32.Parse(Console.ReadLine());
}

}
static void xuatmang(int[] a, int n)
{
Console.Write("Ta co mang a nhu sau:\n");
for (int i = 0; i < n; i++)
{
Console.Write(a[i]+" ");
}
}
static void nhapmatran(int[,] a, int m,int n)
{
for (int i = 0; i < m; i++)
for (int j = 0; j < n; j++)
{
Console.Write("a{0},{1}=",i, j);
a[i,j] = Int32.Parse(Console.ReadLine());
}

}
static void xuatmatran(int[,] a,int m,int n)
{
Console.Write("Ta co ma tran nhu sau:\n");
for (int i = 0; i < m; i++)
{
Console.WriteLine();
for (int j = 0; j < n; j++)
{
Console.Write(a[i, j] + " ");
}
}
}

}
}
liongak
liongak
Cống hiến
Cống hiến

Tổng số bài gửi : 202
Join date : 16/09/2009
Age : 37
Đến từ : Thanh Hóa

Về Đầu Trang Go down

Một số bài ôn tập C# của lớp luyện thi đầu vào Empty Re: Một số bài ôn tập C# của lớp luyện thi đầu vào

Bài gửi by hui 8/1/2010, 17:08

Wan Ho, Lop truong gioi qua'!!!!!!!!!!!
hui
hui
Khởi đầu
Khởi đầu

Tổng số bài gửi : 39
Join date : 23/09/2009
Age : 38

Về Đầu Trang Go down

Một số bài ôn tập C# của lớp luyện thi đầu vào Empty Re: Một số bài ôn tập C# của lớp luyện thi đầu vào

Bài gửi by phamtuananh 8/1/2010, 20:23

Cool man!
phamtuananh
phamtuananh
Cống hiến
Cống hiến

Tổng số bài gửi : 165
Join date : 16/09/2009

Về Đầu Trang Go down

Một số bài ôn tập C# của lớp luyện thi đầu vào Empty Re: Một số bài ôn tập C# của lớp luyện thi đầu vào

Bài gửi by Sponsored content


Sponsored content


Về Đầu Trang Go down

Về Đầu Trang


 
Permissions in this forum:
Bạn không có quyền trả lời bài viết