Ich versuche, Spiele zu entwickeln und für die Grundlagen muss ich Code C# in Visual Studio 2015. Es ist aC# Datei und der Code ist lernen, wie folgt-; erwartet {erwartet in Visual Studio 2015 in einem CS-Dateiprogramm. Es ist eine mathematische Formel
Es ist im Grunde ein Code basiert beim Finden der Entfernung zwischen 2 Punkten.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Program_yash
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome to my program! Here, we're going to find the distance between 2 points in a cartesian coordinate system and the angle between them");
Console.WriteLine("Please enter the x value of the 1st coordinate.");
float pointX1 = float.Parse(Console.ReadLine());
Console.WriteLine("Please enter the y value of the 1st coordinate.");
float pointY1 = float.Parse(Console.ReadLine());
Console.WriteLine("Please enter the x value of the 2nd coordinate.");
float pointX2 = float.Parse(Console.ReadLine());
Console.WriteLine("Please enter the y value of the 2nd coordinate.");
float pointY2 = float.Parse(Console.ReadLine());
double distance = Math.Sqrt((((double)pointX2 - (double)pointX1)) - ((double)pointY2 - (double)pointY1)) * (((double)pointX2 - (double)pointX1))-((double)pointY2 - (double)pointY1)));
Console.WriteLine("The distance between the points is :" + distance);
}
}
}
Der Fehler gezeigt ist, wie unten -
line 22 ; expected
line 22 { expected
Supression Zustand aktiv ist. Ich weiß nicht, wo ich falsch liege. Ich habe C# auf Turbo C gemacht und es ist einfacher als das.
Warum analysieren Sie die Eingabe zu 'float', wenn Sie nur auf' double' umwandeln? Warum nicht einfach gleich "verdoppeln"? – Kyle
@Kyle Ich muss weiter kodieren, wo ich nur float verwenden muss. Also, das ist nur ein Teil des Programms. Ich habe gerade diesen Teil des Codes entfernt und hier eingefügt. –