怎么讲下列C语言程序代码编译成C#的?菜鸟一只,不会啊
/*求一元二次方程ax*x+bx+c=0的解*/ 
#include "stdio.h" 
#include "math.h" 
main() 

float a,b,c,x1,x2,d; 
printf("请输入a:"); 
scanf("%f",&a); 
printf("请输入b:"); 
scanf("%f",&b); 
printf("请输入c:"); 
scanf("%f",&c); 
d=b*b-4*a*c; 
if(d < 0) 
printf("方程没有实数解。\n"); 
if (d==0) 

x1=(-b)/(2*a); 
printf("x1=%f\n",x1); 

if (d>0) 

x1=(-b+sqrt(d))/(2*a); 
x2=(-b-sqrt(d))/(2*a); 
printf("x1=%f,x2=%f\n",x1,x2);} 
}
}

解决方案 »

  1.   

    快速入门:使用 Visual Studio 创建第一个 C# 控制台应用
      

  2.   

    学过C语言的,分分钟钟会用基本的C#,C    C++    C#    本来就是一家人嘛
      

  3.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;namespace CP_1
    {
        class Program
        {
            static void Main()
            {
              
            Console.WriteLine("请输入a:");
               float a =float.Parse(Console.ReadLine());
                Console.WriteLine("请输入b:");
                float b = float.Parse(Console.ReadLine());
                Console.WriteLine("请输入c:");
                float c = float.Parse(Console.ReadLine());
                d=b* b-4*a* c;
            Console.Write(d);
                if (d < 0)
                    Console.WriteLine("方程没有实数解。\n");
                if (d == 0)
                {
                    x1 = (-b) / (2 * a);
                    Console.WriteLine( "x1");
                }
                if (d > 0)
                {
                    x1 = (-b + sqrt(d)) / (2 * a);
                    x2 = (-b - sqrt(d)) / (2 * a);
                  Console.WriteLine("x1"," x2");
                }
            }
        }
        }
        struct ComplexNumber //定义结构类型
        {
            public float a, b, c, x1, x2, d;
        }
    最后运行错误