Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class BigInt{
- private:
- int *p,nr_cif;
- public:
- //BigInt(char *s);
- BigInt();
- BigInt(int x);
- friend ostream & operator <<(ostream&os,BigInt &r);
- };
- BigInt::BigInt()
- {
- nr_cif=0;
- p=NULL;
- }
- BigInt::BigInt(int x)
- {
- int i=1,uc,aux,nr=0;
- aux=x;
- do
- {
- aux/=10;
- nr++;
- }while(aux);
- p=new int[nr];
- aux=x;
- while(aux)
- {
- uc=aux%10;
- aux/=10;
- p[i++]=uc;
- }
- nr_cif=nr;
- }
- ostream & operator <<(ostream & os,BigInt & r)
- {
- for(int i=r.nr_cif;i>=1;i--)
- cout<<r.p[i];
- return os;
- }
- int main()
- {
- int x;
- BigInt w(56);
- cout<<w;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement