方程
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace fangcheng
{class Program{static void Main(string[] args){//方程ax^2+bx+c=0;一元二次方程。求根//△=b^2-4ac;若△<0方程無實(shí)根//若△>0,方程有兩個(gè)不相同的實(shí)根x1 x2//若△=0,方程有兩個(gè)相同的實(shí)根//Console.WriteLine("求方程ax^2+bx+c=0的根的情況:");//Console.Write("請(qǐng)輸入a=");//double a = double.Parse(Console.ReadLine());//Console.Write("請(qǐng)輸入b=");//double b = double.Parse(Console.ReadLine());//Console.Write("請(qǐng)輸入c=");//double c = double.Parse(Console.ReadLine());//if (a == 0)//{// Console.WriteLine("此方程不是一元二次方程!");//}//else//a!=0//{// double de = b * b - 4 * a * c;// if (de < 0)// {// Console.WriteLine("此方程沒有實(shí)數(shù)根!");// double x = (-b + Math.Sqrt(de)) / 2 * a;// Console.WriteLine(x);// }// else //de>=0// {// if (de == 0)// {// Console.WriteLine("此方程有兩個(gè)相同的實(shí)數(shù)根!");// double x = (-b + Math.Sqrt(de)) / 2 * a;// Console.WriteLine("x1=x2="+x);// }// else//de>0// {// Console.WriteLine("此方程有兩個(gè)不同的實(shí)數(shù)根!");// double x1 = (-b + Math.Sqrt(de)) / 2 * a;// double x2 = (-b - Math.Sqrt(de)) / 2 * a;// Console.WriteLine("x1="+x1+",x2="+x2);// }// }//}//Console.ReadLine();//NaN 判斷是不是不是一個(gè)數(shù)字//相親過程//相親過程:你有房子么?你有錢么?你有能力么?//【結(jié)婚吧】【先買房子在結(jié)婚】【先賺錢再買房子再結(jié)婚】都沒有【拜拜~~】//利用if嵌套做相親過程//Console.Write("你有房子么?");//string huida = Console.ReadLine();//if (huida == "有")//{// Console.WriteLine("咱們結(jié)婚吧!");//}//else//{// Console.Write("你有錢嗎?");// huida = Console.ReadLine();// if (huida == "有")// {// Console.WriteLine("先買房子再結(jié)婚!");// }// else// {// Console.WriteLine("那你有能力么?");// huida = Console.ReadLine();// if (huida == "有")// {// Console.WriteLine("先賺錢再買房子再結(jié)婚!");// }// else // {// Console.WriteLine("拜拜!");// }// }//}//Console.ReadLine();//C#與.NET framework 3.5 //c#圖解教程//switch case 多選1 Console.WriteLine("1.漢堡包");Console.WriteLine("2.雞腿");Console.WriteLine("3.雞米花");Console.WriteLine("4.可樂");Console.WriteLine("5.薯?xiàng)l");Console.Write("請(qǐng)輸入你想要的編號(hào):");int shu = int.Parse(Console.ReadLine());switch (shu){case 1:Console.WriteLine("您選擇的是漢堡包!");break;case 2:Console.WriteLine("您選擇的是雞腿!");break;case 3:Console.WriteLine("您選擇的是雞米花!");break;case 4:Console.WriteLine("您選擇的是可樂!");break;case 5:Console.WriteLine("您選擇的是薯?xiàng)l!");break;default:Console.WriteLine("您的輸入有誤!");break;//跳出最近的花括號(hào)
}Console.ReadLine();}}
}
?
轉(zhuǎn)載于:https://www.cnblogs.com/tonyhere/p/5469770.html
總結(jié)
- 上一篇: uva455periodic strin
- 下一篇: linux用户管理最常用的三个文件说明(