//Date: 2003.11.05
//File: bigInt01.cpp
//Author: AOU
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
///////////////////////////////////////////////////////////
// WHAT IS NEW
///////////////////////////////////////////////////////////
/*
*/
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//constants
///////////////////////////////////////////////////////////
const int MAX_SIZE = 10;
const int TEST_COUNT = 25;
const int UNDEFINED = -911;
///////////////////////////////////////////////////////////
//prototypes
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//class CDigit
///////////////////////////////////////////////////////////
class CDigit
{
private:
unsigned int _coef;
unsigned int _expo;
CDigit *_next;
CDigit *_prev;
public:
CDigit(void);
CDigit(char ch);
CDigit(const CDigit &d2);
void display(void) const;
void init(void);
bool operator == (const CDigit &d2) const;
bool operator != (const CDigit &d2) const;
bool operator < (const CDigit &d2) const;
bool operator > (const CDigit &d2) const;
bool operator >= (const CDigit &d2) const;
bool operator <= (const CDigit &d2) const;
CDigit operator + (const CDigit &d2) const;
CDigit operator * (const CDigit &d2) const;
CDigit operator - (const CDigit &d2) const;
CDigit operator / (const CDigit &d2) const;
CDigit & operator = (const CDigit &d2);
friend ostream & operator << (ostream &bob, const CDigit &d2);
};
///////////////////////////////////////////////////////////
//class CBigInt
///////////////////////////////////////////////////////////
class CBigInt
{
private:
CDigit *first;
CDigit *last;
int count;
public:
CBigInt(void);
CBigInt(char ch);
CBigInt(int n);
CBigInt(const CBigInt &i2);
void display(void) const;
void init(void);
bool insert(CDigit x);
bool isSorted(void) const;
void shuffle(void);
void sortBubble(void);
void populate(int n);
CBigInt & operator = (const CBigInt &i2);
bool operator == (const CBigInt &i2) const;
bool operator != (const CBigInt &i2) const;
bool operator < (const CBigInt &i2) const;
bool operator <= (const CBigInt &i2) const;
bool operator > (const CBigInt &i2) const;
bool operator >= (const CBigInt &i2) const;
CBigInt operator + (const CBigInt &i2) const;
CBigInt operator * (const CBigInt &i2) const;
CBigInt operator - (const CBigInt &i2) const;
CBigInt operator / (const CBigInt &i2) const;
friend ostream & operator << (ostream &bob, const CBigInt &bi);
bool hasDistinct(void) const;
bool deleteAtPos(int p);
};
///////////////////////////////////////////////////////////
//main
///////////////////////////////////////////////////////////
void main(void)
{
srand(time(NULL));
}
|