Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cassert>
- #include <stdlib.h>
- using namespace std ;
- class Cellular {
- private :
- int Regula ;
- char *RegulaLancuchBin ;
- public :
- Cellular() {
- RegulaLancuchBin=new char [ 8 ] ;
- if ( ! RegulaLancuchBin ){
- cout<<"brak pamieci dla tablicy RegulaLancuchBin[8]"<<endl ;
- }
- }
- void WczytajRegule ( int dec ){
- assert ( dec>=0 && dec <256);
- Regula=dec ;
- i_to_s (Regula , RegulaLancuchBin , 2 , 8 ) ;
- };
- void i_to_s ( int xx , char * lanc , int nn , int DLUG) ;
- void PokazRegule() {
- cout<<"Regula "<<Regula<<": "<<RegulaLancuchBin<<endl ;
- }
- int ZakodujSasiedztwo ( const int &lewy , const int &srodek , const int &prawy ){
- int liczba_dekod , reg , ref ;
- char znak , zero='0';
- ref=(int ) zero ;
- reg=prawy+2*srodek+4*lewy ;
- znak=*(RegulaLancuchBin+7−reg ) ;
- liczba_dekod =(( int ) ( znak))− ref ;
- return liczba_dekod ;
- }
- };
- void Cellular :: i_to_s ( int xx , char * lanc , int nn , int DLUG){
- long x=xx ;
- int l=DLUG−1;
- long n = nn ;
- int j ;
- for ( j =0; j<DLUG; j++) *( lanc+j )='0' ;
- *( lanc+DLUG)='"0' ;
- if ( ! x ) ;
- else
- {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement