2017-10-16 74 views
-7
  • 错误3只能使用赋值,调用,增量,减量,等待和新对象表达式作为语句。
  • 错误2;预计
  • 错误1个无效表达术语“其他”

我不知道我怎么能解决这个问题。这是代码。3错误。我新编写任何想法什么是错的?

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 

namespace ConsoleApplication3 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      double a, b, c, delta, Pdelta; 
      Console.Write("Podaj a: "); 
      a = Convert.ToDouble(Console.ReadLine()); 
      Console.Write("Podaj b: "); 
      b = Convert.ToDouble(Console.ReadLine()); 
      Console.Write("Podaj c: "); 
      c = Convert.ToDouble(Console.ReadLine()); 
      delta = (b * b - 4 * a * c); 
      Pdelta = Math.Sqrt(delta); 
      //Podanie miejsc zerowych 

      if(delta > 0) 
       Console.WriteLine("x1={0}", (-b-Pdelta)/(2*a)); 
       Console.WriteLine("x2={0}", (-b+Pdelta)/(2*a)); 
      else if (delta == 0) 
       Console.WriteLine("x0={0}", -b/(2*a)); 
      else 
       Console.WriteLine("Brak miejsc zerowych."); 
      Console.ReadKey(true); 
      //koniec 
     } 
    } 
+5

'什么是错'嗯,你没花多少时间格式化你的帖子,你呢?没有读[问]或参加[游览],你有一个可怕的标题。 – Plutonix

+1

我们需要查看完整的代码示例以帮助您。但是,跳出的一件大事就是使用if/else。您需要将这些子句用花括号包装以表明它们是同一个子句。 if(cond){...} else if(cond){...} else {...}等 – JonBee

回答

6

如果您if语句多行,你必须把身体周围的括号:

if(delta > 0) 
{ 
    Console.WriteLine("x1={0}", (-b-Pdelta)/(2*a)); 
    Console.WriteLine("x2={0}", (-b+Pdelta)/(2*a)); 
} 
//... 
相关问题