Advertisement
ewa_tabor

duzeLiczby

Apr 23rd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cctype>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. class duzaLiczba {
  9.  
  10.     int dlugosc;
  11.     char *wsk;
  12.     public:
  13.     friend istream &operator >>(istream &s, duzaLiczba &o1);
  14.     friend ostream &operator <<(ostream &s, duzaLiczba &o1);
  15.     duzaLiczba (){
  16.         dlugosc=0;
  17.         wsk=NULL;
  18.     }
  19.     duzaLiczba(duzaLiczba&o1){
  20.         dlugosc=o1.dlugosc;
  21.         wsk= new char[dlugosc];
  22.     }
  23.    
  24.     duzaLiczba operator = ( duzaLiczba &o1){
  25.         if (this->dlugosc!=0) delete [] this->wsk;
  26.        
  27.         this->dlugosc=o1.dlugosc;
  28.         this->wsk=new char[o1.dlugosc];
  29.         for (int i=0; i<dlugosc; i++){
  30.             this->wsk[i]=o1.wsk[i];
  31.         }
  32.         return *this;
  33.     }
  34.     duzaLiczba operator + (duzaLiczba &o1){
  35.         duzaLiczba wynik(*this);
  36.         if(o1.dlugosc<this->dlugosc) int a=o1.dlugosc;
  37.        
  38.        
  39.  
  40.    
  41.    
  42. };
  43.  
  44. istream &operator >> (istream &s, duzaLiczba &o1){
  45.     if (o1.wsk!=NULL){
  46.         delete [] o1.wsk;
  47.         o1.wsk=NULL;
  48.     }
  49.     string a;
  50.     s>>a;
  51.     o1.dlugosc=a.size();
  52.     o1.wsk = new char[o1.dlugosc];
  53.     for (int i=0; i<o1.dlugosc; i++){
  54.         o1.wsk[i]=a[i];
  55.     }
  56. }
  57.  
  58. ostream &operator << (ostream &s, duzaLiczba &o1){
  59.     for (int i=0; i<o1.dlugosc; i++){
  60.         s<<o1.wsk[i];
  61.     }
  62.  
  63. }
  64.    
  65.  
  66.  
  67. int main(){
  68.     duzaLiczba o1, o2;
  69.     cin>>o1;
  70.     o2=o1;
  71.     cout<<o2;
  72.    
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement