Перевод программы с языка C++ на язык C#
Формулировка задачи:
Есть код на языке C++. Помогите, пожалуйста, перевести, т.е. написать то же самое на языке C# . Спасибо!
#include "iostream.h"
#include "stdlib.h"
#include "conio.h"
#include "math.h"
int main()
{
double r, d1, d2, a, rad;
clrscr();
cout<<"r = ";
cin>>r;
cout<<"d1 = ";
cin>>d1;
cout<<"d2 = ";
cin>>d2;
a = sqrt(pow((d1 / 2), 2) + pow((d2 / 2), 2));
cout<<"a = "<<a;
cout<<"\n";
rad = (d1*d2) / (4*a);
cout<<"\nrad(in) = "<<rad;
if (r == rad)
{
cout<<"\nOK ->>> circle in rhomb";
}
else
{
cout<<"\nNO ->>> circle in rhomb";
}
cout<<"\n";
rad = a / sqrt(2);
cout<<"\nrad(out) = "<<rad;
if (r == rad)
{
cout<<"\nOK ->>> circle out rhomb";
}
else
{
cout<<"\nNO ->>> circle out rhomb";
}
getch();
return 0;
}Решение задачи: «Перевод программы с языка C++ на язык C#»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Мацуй
{
class Program
{
static void Main(string[] args)
{
double r, d1, d2, a, rad;
Console.WriteLine("r = ");
r = double.Parse(Console.ReadLine());
Console.WriteLine("d1 = ");
d1 = double.Parse(Console.ReadLine());
Console.WriteLine("d2 = ");
d2 = double.Parse(Console.ReadLine());
a = Math.Sqrt(Math.Pow((d1 / 2), 2) + Math.Pow((d2 / 2), 2));
Console.WriteLine("a = " + a );
Console.WriteLine("\n");
rad = (d1 * d2) / 4 * a;
Console.WriteLine("\nrad(in) = " + rad);
if (r == rad)
{
Console.WriteLine("\nOK ->>> circle in rhomb");
}
else
{
Console.WriteLine("\nNO ->>> circle in rhomb");
}
Console.WriteLine("\n");
rad = a / Math.Sqrt(2);
Console.WriteLine("\nrad(out) = " + rad);
if (r == rad)
{
Console.WriteLine("\nOK ->>> circle out rhomb");
}
else
{
Console.WriteLine("\nNO ->>> circle in rhomb");
}
Console.ReadLine();
}
}
}