Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include <iostream>
  2. #include <cassert>
  3. #include <stdlib.h>
  4.  
  5. using namespace std ;
  6.  
  7. class Cellular {
  8. private :
  9. int Regula ;
  10. char *RegulaLancuchBin ;
  11. public :
  12.  
  13.  Cellular() {
  14. RegulaLancuchBin=new char [ 8 ] ;
  15. if ( ! RegulaLancuchBin ){
  16. cout<<"brak pamieci dla tablicy RegulaLancuchBin[8]"<<endl ;
  17. }
  18. }
  19.  
  20. void WczytajRegule ( int dec ){
  21. assert ( dec>=0 && dec <256);
  22. Regula=dec ;
  23. i_to_s (Regula , RegulaLancuchBin , 2 , 8 ) ;
  24. };
  25.  
  26. void i_to_s ( int xx , char * lanc , int nn , int DLUG) ;
  27. void PokazRegule() {
  28. cout<<"Regula "<<Regula<<": "<<RegulaLancuchBin<<endl ;
  29. }
  30. int ZakodujSasiedztwo ( const int &lewy , const int &srodek , const int &prawy ){
  31.     int liczba_dekod , reg , ref ;
  32.     char znak , zero='0';
  33.     ref=(int ) zero ;
  34.  
  35.     reg=prawy+2*srodek+4*lewy ;
  36.     znak=*(RegulaLancuchBin+7−reg ) ;
  37.     liczba_dekod =(( int ) ( znak))− ref ;
  38.     return liczba_dekod ;
  39. }
  40. };
  41.  
  42.  
  43.  void Cellular :: i_to_s ( int xx , char * lanc , int nn , int DLUG){
  44. long x=xx ;
  45. int l=DLUG−1;
  46. long n = nn ;
  47. int j ;
  48.  
  49. for ( j =0; j<DLUG; j++) *( lanc+j )='0' ;
  50. *( lanc+DLUG)='"0' ;
  51.  
  52.  if ( ! x ) ;
  53.  else
  54.  {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement