本文整理汇总了C#中Lab301.Fraction类的典型用法代码示例。如果您正苦于以下问题:C# Fraction类的具体用法?C# Fraction怎么用?C# Fraction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Fraction类属于Lab301命名空间,在下文中一共展示了Fraction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Fraction
public static Fraction operator +(Fraction frac1, Fraction frac2)
{
Fraction frac5 = new Fraction();
frac5.setB((frac1.den * frac2.den));
frac5.setA(((frac1.num * frac2.den) + (frac2.num * frac1.den)));
return frac5;
}
开发者ID:necklecez,项目名称:week-3,代码行数:7,代码来源:Fraction.cs
示例2: Fraction
//+ overload
public static Fraction operator +(Fraction frac, int num )
{
Fraction result = new Fraction();
result.Numer = (num * frac.Demo) + frac.Numer;
result.Demo = (1) * frac.Demo;
return result;
}
开发者ID:normandysr1,项目名称:week-3,代码行数:8,代码来源:fraction.cs
示例3: Fraction
public static Fraction operator +(Fraction a,Fraction b)
{
Fraction c = new Fraction();
int lcm = LCM(a.Denom, b.Denom);
c.setValue(a.Numer * (lcm / a.Denom) + b.Numer * (lcm / b.Denom), lcm);
return c;
}
开发者ID:cpe200-158-sec2-0560,项目名称:week-3,代码行数:7,代码来源:Fraction.cs
示例4: Fraction
public Fraction(Fraction input_Frac)
{
_Numer = input_Frac.Numer;
_Denom = input_Frac.Denom;
_Count ++;
}
开发者ID:cpe200-158-sec1-0549,项目名称:week-3,代码行数:7,代码来源:Fraction.cs
示例5: Fraction
public static Fraction operator +(Fraction x, Fraction y)
{
Fraction result = new Fraction();
result.Numer = x.Numer * y.Denom + y.Numer * y.Denom;
result.Denom = y.Denom * x.Denom;
return result;
}
开发者ID:cpe200-158-sec2-0611,项目名称:week-3,代码行数:8,代码来源:Fraction.cs
示例6: Fraction
public static Fraction operator +(Fraction a, Fraction b)
{
Fraction c = new Fraction();
c.Numerator = (a.Numerator * b.Denominator) + (b.Numerator * a.Denominator);
c.Denominator = (a.Denominator * b.Denominator);
c.setValue(c.Numerator, c.Denominator);
return c;
}
开发者ID:cpe200-158-sec2-0544,项目名称:week-3,代码行数:8,代码来源:Fraction.cs
示例7: Fraction
//fraction+int
public static Fraction operator +(Fraction f1, int f2)
{
int a = 0, b = 0;
a = (f2 * f1.Denom) + f1.Numer;
b = f1.Denom;
Fraction f = new Fraction(a, b);
f = f.Pudsad(f);
return f;
}
开发者ID:cpe200-158-sec1-0566,项目名称:week-3,代码行数:10,代码来源:Fraction.cs
示例8: Fraction
public Fraction(Fraction a)
{
_Numer = a._Numer;
if (a.Denom == 0)
_Denom = 1;
else
_Denom = a.Denom;
_Count++;
}
开发者ID:Bankzac2,项目名称:week-3,代码行数:9,代码来源:Fraction.cs
示例9: Main
public static void Main(string[] args)
{
Fraction r1 = new Fraction();
Fraction r2 = new Fraction(2);
Fraction r3 = new Fraction(3,9);
Console.WriteLine ("***** " + Fraction.Count + " Fraction objects have been created *****");
Fraction r4 = r1+r2;
Fraction r5 = r2-r3;
Fraction r6 = new Fraction(100,50);
r6 += r2;
// Fraction r7 = new Fraction(r3); // case#1
Fraction r7 = r3; // case#2
r7++;
Console.WriteLine ("***** " + Fraction.Count + " Fraction objects have been created *****");
Fraction r8 = 10 - (new Fraction(80,40));
Fraction r9 = (new Fraction(5,25)) + 1;
Console.WriteLine ("***** " + Fraction.Count + " Fraction objects have been created *****");
r1.output();
r2.output();
r3.output();
r4.output();
r5.output();
r6.output();
r7.output();
r8.output();
r9.output();
/*Console.WriteLine (r2);
Console.WriteLine (r3);
Console.WriteLine (r4);
Console.WriteLine (r5);
Console.WriteLine (r6);
Console.WriteLine (r7);
Console.WriteLine (r8);
Console.WriteLine (r9);*/
Console.WriteLine (r2==r4);
Console.WriteLine (r4.Equals (r2)); // Equals method must be overriden
Console.WriteLine (r2!=r4);
r3.setValue (10,12/3*0);
r3.output();
//Console.WriteLine (r3);
Console.WriteLine ("***** " + Fraction.Count + " Fraction objects have been created *****");
Console.WriteLine("GCD of 3650 and 360: " + Fraction.GCD (3650,360));
Console.WriteLine("GCD of 3600 and 360: " + Fraction.GCD (3600,360));
}
开发者ID:necklecez,项目名称:week-3,代码行数:55,代码来源:Program.cs
示例10: Fraction
public static Fraction operator +(Fraction f_left, int num)
{
Fraction added = new Fraction();
added.Numer = f_left.Numer + (num * f_left.Denom);
added.Denom = f_left.Denom;
return added;
}
开发者ID:cpe200-158-sec1-0601,项目名称:week-3,代码行数:7,代码来源:Fraction.cs
示例11: Fraction
public static Fraction operator +(Fraction x , Fraction y)
{
Fraction a = new Fraction();
a.setValue((x.Numer * y.Demon) + (y.Numer * x.Demon), (x.Demon * y.Demon));
return a;
}
开发者ID:cpe200-158-sec02-0569,项目名称:week-3,代码行数:6,代码来源:Fraction.cs
示例12: Equals
public bool Equals(Fraction a)
{
return (this.numer / this.denom == a.numer / a.denom);
}
开发者ID:cpe200-158-sec1-0614,项目名称:week-3,代码行数:4,代码来源:Fraction.cs
示例13: Equals
public bool Equals(Fraction a)
{
return (this == a);
}
开发者ID:cpe200-158-sec2-0609,项目名称:week-3,代码行数:4,代码来源:Fraction.cs
示例14: Equals
public bool Equals(Fraction i)
{
return (this.numer / this.decom == i.numer / i.decom);
}
开发者ID:cpe200-158-sec2-0548,项目名称:week-3,代码行数:4,代码来源:Franction.cs
示例15: Equals
public bool Equals(Fraction c)
{
return (numer == c.numer && denom == c.denom);
}
开发者ID:cpe200-158-sec2-0573,项目名称:week-3,代码行数:4,代码来源:Fraction.cs
示例16: Fraction
public Fraction(Fraction i)
{
numer = i.numer;
decom = i.decom;
Count++;
}
开发者ID:cpe200-158-sec2-0548,项目名称:week-3,代码行数:6,代码来源:Franction.cs
示例17: Equals
public bool Equals(Fraction a)
{
return (a.numer == this.numer && a.denom == this.denom);
}
开发者ID:tuinuisureerat,项目名称:week-3,代码行数:4,代码来源:Fraction.cs
示例18: Fraction
public Fraction(Fraction a)
{
_numer = a._numer;
_denom = a._denom;
_count++;
}
开发者ID:cpe200-158-sec2-0609,项目名称:week-3,代码行数:6,代码来源:Fraction.cs
示例19: Fraction
public Fraction(Fraction a)
{
numer = a.numer;
denom = a.denom;
Count++;
}
开发者ID:tuinuisureerat,项目名称:week-3,代码行数:6,代码来源:Fraction.cs
示例20: Fraction
public Fraction(Fraction a)
{
numer = a.numer;
denom = a.denom;
}
开发者ID:cpe200-158-sec1-0614,项目名称:week-3,代码行数:5,代码来源:Fraction.cs
注:本文中的Lab301.Fraction类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论