c# 분수 계산, 기약 분수
- 최초 등록일
- 2012.11.22
- 최종 저작일
- 2012.11
- 15페이지/ MS 워드
- 가격 1,000원
목차
1. 1~4번
본문내용
using System;
namespace Helloworld
{
//사칙연산타입
enum OpType { Add, Subtract, Multiply, Divide };
//분수생성
class Fraction
{
//분자,분모
private int numerator;
private int denominator;
//분자,분모 기약
private int lowest_num;
private int lowest_denom;
//생성자
public Fraction(int n, int d)
{
int gcd_value;
numerator = n;
denominator = d;
gcd_value = gcd(n, d);
lowest_num = numerator / gcd_value;
lowest_denom = denominator / gcd_value;
if (lowest_denom < 0)
{
lowest_num = -lowest_num;
lowest_denom = -lowest_denom;
}
}
public int Numerator
{
get { return numerator; }
set { numerator = value; }
}
참고 자료
없음