20150828实例

1、查看一元二次方程有木有实根

2、输入年月日,判断日期格式是否正确

3、如何用计算机生成随机数

4、1-100的所有偶数

5、取所有带7 的数

6、随机出一个数

7、求100以内所有数的和

////查看一元二次方程有木有实根

////输入
//Console.WriteLine("一元二次方程:a*x*x+b*x+c=0(a!=0)");
//Console.Write("a=");
//int a = Convert.ToInt16(Console.ReadLine());
//Console.Write("b=");
//int b = Convert.ToInt16(Console.ReadLine());
//Console.Write("c=");
//int c = Convert.ToInt16(Console.ReadLine());

////运算及输出
//if (a == 0)
//{
// Console.WriteLine("这不是一元二次方程");
//}
//else
//{
// int delta = b * b - 4 * a * c;
// if (delta > 0)
// {
// Console.WriteLine("方程里面有两个不等实根");
// }
// else if (delta == 0)
// {
// Console.WriteLine("有两个相等实根");
// }
// else
// {
// Console.WriteLine("没有实根");
// }
//}


//输入年月日,判断日期格式是否正确
/*
* 年份在0001 - 9999之间
* 月份在1 - 12之间
* 日 月份 1 3 5 7 8 10 12 是 1-13
* 4 6 9 11 是1-30之间
* 2月是
* 闰年是1-29
* 平年是1-28
*/
//输入
//Console.Write("请输入年份:");
//int year = Convert.ToInt16(Console.ReadLine());
//Console.Write("请输入月份:");
//int month = Convert.ToInt16(Console.ReadLine());
//Console.Write("请输入日:");
//int date = Convert.ToInt16(Console.ReadLine());
//if (year >= 1 & year < 10000)
//{
// if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
// {
// if (date >= 1 && date <= 31)
// {
// Console.Write("您输入的日期为:" + year + "-" + month + "-" + date + " ");
// Console.WriteLine("日期格式正确");
// }
// else
// {
// Console.WriteLine("输入有误");
// }
// }
// else
// {
// if (month == 4 || month == 6 || month == 9 || month == 11)
// {
// if (date >= 1 && date <= 30)
// {
// Console.Write("您输入的日期为:" + year + "-" + month + "-" + date + " ");
// Console.WriteLine("日期格式正确");
// }
// else
// {
// Console.WriteLine("输入有误");
// }
// }
// else
// {
// if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0)
// {
// if (date >= 1 && date <= 29)
// {
// Console.Write("您输入的日期为:" + year + "-" + month + "-" + date + " ");
// Console.WriteLine("日期格式正确");
// }
// else
// {
// Console.WriteLine("输入有误");
// }
// }
// else
// {
// if (date >= 1 && date <= 28)
// {
// Console.Write("您输入的日期为:" + year + "-" + month + "-" + date+" ");
// Console.WriteLine("日期格式正确");
// }
// else
// {
// Console.WriteLine("输入有误");
// }
// }
// }

// }
//}
//else
//{
// Console.WriteLine("输入有误");
//}

////如何用计算机生成随机数
//Random rand = new Random();
//int n1 = rand.Next(36) + 1;
//int n2 = rand.Next(36) + 1;
//int n3 = rand.Next(36) + 1;
//int n4 = rand.Next(36) + 1;
//int n5 = rand.Next(36) + 1;
//int n6 = rand.Next(36) + 1;
//int n7 = rand.Next(36) + 1;

//Console.WriteLine(n1+n2+n3+n4+n5+n6+n7);

////1-100的所有偶数
//for (int a = 1; a <= 100; a++)
//{
// if (a % 2 == 0)
// {

// Console.Write(a + " ");
// }
//}

////取所有带7 的数
//for (int a = 1; a <= 100; a++)
//{
// if(a%7==0 || a%10==7 || a/10==7 )
// {
// Console.Write(a + " ");
// }
//}

////随机出一个数
//Console.Write("A:");
//string n1 = Console.ReadLine();
//Console.Write("B:");
//string n2 = Console.ReadLine();

//Random rand = new Random();
//int n = rand.Next(100) + 1;
//if (n >= 0 && n < 50)
//{
// Console.WriteLine(n1+n2+n);
// Console.WriteLine("GG");
//}


////求100以内所有数的和
//int sum = 0;
//for (int i = 1; i <= 100;i++ )
//{
// sum = sum + i;
//}
//Console.WriteLine(sum);

原文地址:https://www.cnblogs.com/hz1234/p/4766554.html