ÄÚÈÝ·¢²¼¸üÐÂʱ¼ä : 2026/9/6 12:45:17ÐÇÆÚÒ» ÏÂÃæÊÇÎÄÕµÄÈ«²¿ÄÚÈÝÇëÈÏÕæÔĶÁ¡£
ʵÑ鱨¸æ¶þ
ÐÕ Ãû רҵ Èí¼þ¹¤³Ì ¿Î³ÌÃûC#³ÌÐòÉè¼Æ ³Æ Ò»¡¢ÊµÑéÃû³Æ£º ʵÑé2 ¶þ¡¢ÊµÑéÄ¿µÄ£º ÕÆÎÕʹÓÃÃüÁîÐпª·¢¼òµ¥µÄC#Ó¦ÓóÌÐò ÕÆÎÕʹÓÃVisual Studio±àд¿ØÖÆÌ¨Ó¦ÓóÌÐò ÕÆÎÕVisual Studio»·¾³Ï³ÌÐòµÄ¸ú×Ùµ÷ÊÔ Á˽âVisual StudioÔÚÏß°ïÖúµÄʹÓÃ ÕÆÎÕÓ¦ÓóÌÐòÃüÁîÐвÎÊýµÄʹÓà Èý¡¢ÊµÑéÄÚÈݼ°ÒªÇó ÀûÓÃADO.NETÍê³ÉÊý¾ÝµÄÔö¡¢É¾¡¢¸Ä¡¢²é ËÄ¡¢ÊµÑé²ÄÁÏ¡¢¹¤¾ß¡¢»òÈí¼þ Windows XP Professional SP3 Visual Studio 2005 Î塢ʵÑé²½Öè¡¢½á¹û£¨»ò¼Ç¼£© ʵÑé¶þ:³ÌÐòÁ÷³Ì¿ØÖÆ 2-1ÊäÈë°ë¾¶£¬Çó¶ÔÓ¦µÄÔ²µÄÖܳ¤¡¢Ãæ»ý¡¢¶ÔÓ¦ÇòÌåµÄÌå»ý¡£ ÔËÐнá¹û£º ʵÑé´úÂ룺 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _2_1 { class Program { static void Main(string[] args) { const double PI = 3.14159; double r, perimeter, area, volume; Console.Write (\ÇëÊäÈë°ë¾¶:\ String s = Console.ReadLine(); r = double.Parse(s); Console.WriteLine(\Ô²µÄ°ë¾¶Îª={0}\ perimeter = 2 * PI * r; area = PI * r * r; volume = 4 / 3 * PI * Math.Pow(r, 3); Console.WriteLine(\Ô²µÄÖܳ¤Îª={0}£¬Ãæ»ýΪ={1}\ Console.WriteLine(\ÇòÌåµÄÌå»ý={0}\ Console.ReadLine(); } } } 2-2ÇóÈý½ÇÐεÄÖܳ¤ºÍÃæ»ý ÔËÐнá¹û£º ʵÑé´úÂ룺 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _2_2 { class Program { static void Main(string[] args) { double a, b, c, p, h, area; Console.Write(\ÇëÊäÈëÈý½ÇÐεıßa:\ string s = Console.ReadLine(); a = double.Parse(s); Console .Write (\ÇëÊäÈëÈý½ÇÐεıßb:\ s = Console.ReadLine(); b = double.Parse(s); Console.Write(\ÇëÊäÈëÈý½ÇÐεıßc:\ s = Console.ReadLine(); c = double.Parse(s); if (a > 0 && b > 0 && c > 0 && a + b > c && a + c > b && b + c > a) { Console.WriteLine(\Èý½ÇÐÎÈý±ß·Ö±ðΪ£ºa={0},b={1},c={2}\ p = a + b + c; h = p / 2; area = Math.Sqrt(h * (h - a) * (h - b) * (h - c)); Console.WriteLine(\Èý½ÇÐεÄÖܳ¤={0},Ãæ»ýΪ={1}\ } else Console.WriteLine(\ÎÞ·¨¹¹³ÉÈý½ÇÐΣ¡\ Console.ReadKey(); } } } 2-3·Ö¶Îº¯ÊýµÄʵÏÖ ÔËÐнá¹û ʵÑé´úÂ룺 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _2_3_2 { class Program { static void Main(string[] args) { double x, y; Console .Write (\ÇëÊäÈëx£º\ string s = Console.ReadLine(); x = double.Parse(s); y = (x * x - 3 * x) / (x + 1) + 2 * Math.PI + Math.Sin(x); if(x<0) y=Math.Log(-5*x)+6*Math .Sqrt (Math .Abs (x)+Math .Pow (Math.E ,4)-Math .Pow (x+1,3)); Console .WriteLine (\·½·¨Ò»:x={0},y={1}\ if(x>=0) y = (x * x - 3 * x) / (x + 1) + 2 * Math.PI + Math.Sin(x); if(x<0) y=Math.Log(-5*x)+6*Math .Sqrt (Math .Abs (x)+Math .Pow (Math.E,4)-Math .Pow (x+1,3)); Console .WriteLine (\·½·¨¶þ:x={0},y={1}\ if(x>=0) y = (x * x - 3 * x) / (x + 1) + 2 * Math.PI + Math.Sin(x); else y=Math.Log(-5*x)+6*Math .Sqrt (Math .Abs (x)+Math .Pow (Math .E,4)-Math .Pow (x+1,3)); Console .WriteLine (\·½·¨Èý:x={0},y={1}\ y=(x>=0)?(x * x - 3 * x) / (x + 1) + 2 * Math.PI + Math.Sin(x):Math.Log(-5*x)+6*Math .Sqrt (Math .Abs (x)+Math .Pow (Math .E,4)-Math .Pow (x+1,3)); Console .WriteLine (\·½·¨ËÄ:x={0},y={1}\ Console .ReadKey (); } } } 2-4Èý¸öÊý±È½Ï´óС ÔËÐнá¹û£º ʵÑé´úÂ룺 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _2__4 { class Program { static void Main(string[] args) { int a, b, c, a1, b1, c1, t, Nmax, Nmin, Nmid; Random rMun = new Random(); a = rMun.Next(101); b = rMun.Next(101); c= rMun.Next(101); Console.WriteLine(\Ôʼֵ£ºa={0},b={1},c={2}\ a1 = a; b1 = b; c1 = c; if (a > b) { t = a; a = b; b = t; } if (a > c) { t = a; a = c; c = t; } if (b > c) { t = b; b = c; c = t; } Console.WriteLine((\·½·¨Ò»)ÉýÐòÖµ£ºa={0},b={1},c={2}\ a = a1; b = b1; c = c1; Nmax =Math .Max (Math .Max (a,b),c); Nmin = Math.Min(Math.Min(a, b), c); Nmid = a + b + c - Nmax - Nmin; a = Nmin; b = Nmid; c = Nmax; Console.WriteLine(\·½·¨¶þ)ÉýÐòÖµ£ºa={0},b={1},c={2}\