c# 问题 注释怎么写
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/13 00:17:19
c# 问题 注释怎么写
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ComplexNumber x, y;
Console.Write("Enter the real part of complex number x:");
double realPart = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the real part of complex number x:");
double imaginaryPart = Convert.ToDouble(Console.ReadLine());
x = new ComplexNumber(realPart, imaginaryPart);
Console.Write("\nEnter the real part of complex number y:");
realPart = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the imaginary part of complex number y:");
imaginaryPart = Convert.ToDouble(Console.ReadLine());
y = new ComplexNumber(realPart, imaginaryPart);
Console.WriteLine();
Console.WriteLine("{0}+{1}={2}", x, y, x + y);
Console.WriteLine("{0}-{1}={2}", x, y, x - y);
Console.WriteLine("{0}*{1}={2}", x, y, x * y);
}
public class ComplexNumber
{
public double Real { get;private set;}
public double Imaginary { get;private set;}
public ComplexNumber(double a, double b)
{
Real = a;
Imaginary = b;
}
public override string ToString()
{
return string.Format("({0}{1}{2}i)", Real, (Imaginary < 0 ? "-" : "+"), Math.Abs(Imaginary));
}
public static ComplexNumber operator +(ComplexNumber x, ComplexNumber y)
{
return new ComplexNumber(x.Real + y.Real, x.Imaginary + y.Imaginary);
}
public static ComplexNumber operator -(ComplexNumber x, ComplexNumber y)
{
return new ComplexNumber(x.Real - y.Real, x.Imaginary - y.Imaginary);
}
public static ComplexNumber operator *(ComplexNumber x, ComplexNumber y)
{
return new ComplexNumber(x.Real * y.Real - x.Imaginary * y.Imaginary, x.Real * y.Imaginary + y.Real * x.Imaginary);
}
}
}
}
能把注释都写出来么,谢谢
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ComplexNumber x, y;
Console.Write("Enter the real part of complex number x:");
double realPart = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the real part of complex number x:");
double imaginaryPart = Convert.ToDouble(Console.ReadLine());
x = new ComplexNumber(realPart, imaginaryPart);
Console.Write("\nEnter the real part of complex number y:");
realPart = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the imaginary part of complex number y:");
imaginaryPart = Convert.ToDouble(Console.ReadLine());
y = new ComplexNumber(realPart, imaginaryPart);
Console.WriteLine();
Console.WriteLine("{0}+{1}={2}", x, y, x + y);
Console.WriteLine("{0}-{1}={2}", x, y, x - y);
Console.WriteLine("{0}*{1}={2}", x, y, x * y);
}
public class ComplexNumber
{
public double Real { get;private set;}
public double Imaginary { get;private set;}
public ComplexNumber(double a, double b)
{
Real = a;
Imaginary = b;
}
public override string ToString()
{
return string.Format("({0}{1}{2}i)", Real, (Imaginary < 0 ? "-" : "+"), Math.Abs(Imaginary));
}
public static ComplexNumber operator +(ComplexNumber x, ComplexNumber y)
{
return new ComplexNumber(x.Real + y.Real, x.Imaginary + y.Imaginary);
}
public static ComplexNumber operator -(ComplexNumber x, ComplexNumber y)
{
return new ComplexNumber(x.Real - y.Real, x.Imaginary - y.Imaginary);
}
public static ComplexNumber operator *(ComplexNumber x, ComplexNumber y)
{
return new ComplexNumber(x.Real * y.Real - x.Imaginary * y.Imaginary, x.Real * y.Imaginary + y.Real * x.Imaginary);
}
}
}
}
能把注释都写出来么,谢谢
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ComplexNumber x,y;//声明下面类的2实例对象
Console.Write("Enter the real part of complex number x:");
double realPart = Convert.ToDouble(Console.ReadLine());//输入数字
Console.Write("Enter the real part of complex number x:");
double imaginaryPart = Convert.ToDouble(Console.ReadLine());//输入数字
x = new ComplexNumber(realPart,imaginaryPart);//new出来对象x初始化
Console.Write("\nEnter the real part of complex number y:");
realPart = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the imaginary part of complex number y:");
imaginaryPart = Convert.ToDouble(Console.ReadLine());
y = new ComplexNumber(realPart,imaginaryPart);//同上面x
Console.WriteLine();//换行
Console.WriteLine("{0}+{1}={2}",x,y,x + y);//输出下面运算符重载算出来的值
Console.WriteLine("{0}-{1}={2}",x,y,x - y);//输出下面运算符重载算出来的值
Console.WriteLine("{0}*{1}={2}",x,y,x * y);//输出下面运算符重载算出来的值
}
public class ComplexNumber
{
public double Real { get; private set; }//属性定义
public double Imaginary { get; private set; }//属性定义
public ComplexNumber(double a,double b)
{
Real = a;//构造函数定义
Imaginary = b;
}
public override string ToString()
{
return string.Format("({0}{1}{2}i)",Real,(Imaginary < 0 "-" :"+"),Math.Abs(Imaginary));
}
public static ComplexNumber operator +(ComplexNumber x,ComplexNumber y)
{
return new ComplexNumber(x.Real + y.Real,x.Imaginary + y.Imaginary);//运算符重载+
}
public static ComplexNumber operator -(ComplexNumber x,ComplexNumber y)
{
return new ComplexNumber(x.Real - y.Real,x.Imaginary - y.Imaginary);//运算符重载—
}
public static ComplexNumber operator *(ComplexNumber x,ComplexNumber y)
{
return new ComplexNumber(x.Real * y.Real - x.Imaginary * y.Imaginary,x.Real * y.Imaginary + y.Real * x.Imaginary);//运算符重载*
}
}
}
}
不懂可以再交流
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ComplexNumber x,y;//声明下面类的2实例对象
Console.Write("Enter the real part of complex number x:");
double realPart = Convert.ToDouble(Console.ReadLine());//输入数字
Console.Write("Enter the real part of complex number x:");
double imaginaryPart = Convert.ToDouble(Console.ReadLine());//输入数字
x = new ComplexNumber(realPart,imaginaryPart);//new出来对象x初始化
Console.Write("\nEnter the real part of complex number y:");
realPart = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the imaginary part of complex number y:");
imaginaryPart = Convert.ToDouble(Console.ReadLine());
y = new ComplexNumber(realPart,imaginaryPart);//同上面x
Console.WriteLine();//换行
Console.WriteLine("{0}+{1}={2}",x,y,x + y);//输出下面运算符重载算出来的值
Console.WriteLine("{0}-{1}={2}",x,y,x - y);//输出下面运算符重载算出来的值
Console.WriteLine("{0}*{1}={2}",x,y,x * y);//输出下面运算符重载算出来的值
}
public class ComplexNumber
{
public double Real { get; private set; }//属性定义
public double Imaginary { get; private set; }//属性定义
public ComplexNumber(double a,double b)
{
Real = a;//构造函数定义
Imaginary = b;
}
public override string ToString()
{
return string.Format("({0}{1}{2}i)",Real,(Imaginary < 0 "-" :"+"),Math.Abs(Imaginary));
}
public static ComplexNumber operator +(ComplexNumber x,ComplexNumber y)
{
return new ComplexNumber(x.Real + y.Real,x.Imaginary + y.Imaginary);//运算符重载+
}
public static ComplexNumber operator -(ComplexNumber x,ComplexNumber y)
{
return new ComplexNumber(x.Real - y.Real,x.Imaginary - y.Imaginary);//运算符重载—
}
public static ComplexNumber operator *(ComplexNumber x,ComplexNumber y)
{
return new ComplexNumber(x.Real * y.Real - x.Imaginary * y.Imaginary,x.Real * y.Imaginary + y.Real * x.Imaginary);//运算符重载*
}
}
}
}
不懂可以再交流