A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 693
Function: getPaste

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

Re: Re: fff - Stikked
From lichnow, 11 Years ago, written in C.
This paste is a reply to Re: fff from lichnow - go back
Embed
Viewing differences between Re: fff and Re: Re: fff
<?php
echo 'Hellow';
/**
*        ?????AVL
*        ???????????????????????????????acm??
*        ??avl?acm?????????treap??
*        avl????????????????????????
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <time.h>
#include <queue>
using namespace std;

int COUNT;        //????????????
int HEIGHT; //??????

//????
class DNode
{
public:
        int data;
        DNode():data(0){};
        DNode(int d):data(d){}

        bool operator = (const DNode &d){
                return data = d.data;
        }
        bool operator == (const DNode &d){
                return data == d.data;
        }
        bool operator > (const DNode &d){
                return data > d.data;
        }
        bool operator < (const DNode &d){
                return data < d.data;
        }
        void show(){
                cout << endl;
                cout << "***************" << endl;
                cout << "data: " << data << endl;
        }
};
//treap???
template<class T>
class AVLNode{
private:
        int hgt;        //?????
public:
        T data;
        int count;
        
        AVLNode<T> *son[2];        //0?????1????
        AVLNode<T>(T data):data(data), count(1){
                son[0] = son[1] = NULL;
                hgt = 1;
        }

        int max(int a, int b){return a > b ? a : b;}
        void show(){
                data.show();
                cout << "c hgt: " << this->height() << endl;
                cout << "l hgt: " << this->son[0]->height() << endl;
                cout << "r hgt: " << this->son[1]->height() << endl;
                cout << "count: " << count << endl;
                cout << endl;
        }
        int height(){
                if(NULL == this)
                        return 0;
                return _getHeight(this);
        }
        int _getHeight(AVLNode<T> * cur){
                if(NULL == cur)
                        return 0;
                return 1 + max(_getHeight(cur->son[0]), _getHeight(cur->son[1]));
        }
        void setHeight(){
                hgt = _getHeight(this);
        }
};

//AVL Tree
//???T?????????
template<class T>
class AVLTree{
private:
        AVLNode<T> * root;                //???
        int hgt;                        //????
        int size;                        //?????????
        void _insert(AVLNode<T> *& cur, T data);
        void _mid_travel(AVLNode<T> *cur);
        //????
        void _cengci_travel(AVLNode<T> *cur);
        //??????????, ???????????? ????????????????
        //?treap???????
        void _singleRoate(AVLNode<T> *& cur, int dir);
        //??????????
        void _doubleRoate(AVLNode<T> *& cur, int dir);
        int max(int a, int b){
                return a > b ? a : b;
        }
public:
        AVLTree():root(NULL), hgt(0){}
        void insert(const T & data);
        void mid_travel();
        int height(){
                return root->height();
        }
        //????
        void cengci_travel(){
                _cengci_travel(root);
        };

};

/*************  ??????**********************/
template<class T>
void AVLTree<T>::_insert(AVLNode<T> *& cur, T data){
        if(NULL == cur){
                cur = new AVLNode<T>(data);
        }else if(data == cur->data){
                cur->count++;
        }else{
                int dir = (data > cur->data);
                _insert(cur->son[dir], data);
                if(2 <= cur->son[dir]->height() - cur->son[!dir]->height()){
                        bool lr = (data > cur->data);
                        lr ? _singleRoate(cur, dir) : _doubleRoate(cur, dir);
                }
        }
        cur->setHeight();
        //cout << "set height: " << endl;
        //cur->show();
}
template<class T>
void AVLTree<T>::_mid_travel(AVLNode<T> * cur){
        if(NULL != cur){
                //??????
                _mid_travel(cur->son[0]);
                //if(abs(cur->son[0]->height() - cur->son[1]->height()) >= 2)
                {
                        cur->show();
                }
                _mid_travel(cur->son[1]);
        }
}
//?????
//?????????0 ???
template<class T>
void AVLTree<T>::_cengci_travel(AVLNode<T> * cur){
        if(NULL == cur)
                return;
        queue<AVLNode<T>*> q;
        q.push(cur);
        AVLNode<T> *top = NULL;
        queue<AVLNode<T>*> tmp;
        
        while(!q.empty()){
                while(!q.empty()){
                        top = q.front();
                        q.pop();
                        if(NULL == top){
                                //?#????????#?????#
                                cout << '#' << " ";
                                tmp.push(top);
                        }else{
                                cout << top->data.data << " ";
                                tmp.push(top->son[0]);
                                tmp.push(top->son[1]);
                        }
                }
                bool flag = false;
                while(!tmp.empty()){
                        if(NULL != tmp.front())
                                flag = true;
                        q.push(tmp.front());
                        tmp.pop();
                }
                cout << endl;
                if(!flag)
                        break;
        }
}

//??????????
//dir = 0?,????????????
template<class T>
void AVLTree<T>::_singleRoate(AVLNode<T> *& cur, int dir){
        AVLNode<T> *& k2 = cur, * k1 = k2->son[dir];        //k2 ?????
        k2->son[dir] = k1->son[!dir];
        k1->son[!dir] = k2;
        k2 = k1;
        
        k2->setHeight();
        k1->setHeight();
}
//???????????
//dir = 0?????? ???????
template<class T>
void AVLTree<T>::_doubleRoate(AVLNode<T> *& cur, int dir){
        _singleRoate(cur->son[dir], !dir);
        _singleRoate(cur, dir);
}

/*************  ??????????**********************/
template<class T>
void AVLTree<T>::insert(const T & data){
        _insert(root, data);
}
template<class T>
void AVLTree<T>::mid_travel(){
        _mid_travel(root);
}

int main(){
        AVLTree<DNode>* avlt = new AVLTree<DNode>();
        const int num = 30;
        for(int i = 0; i < num; i++){
                DNode * d = new DNode(i);
                avlt->insert(*d);

        }
        cout << "*************????***************" << endl;
        avlt->mid_travel();
        cout << "**************??????**********" << endl;

        cout << "*************??????***************" << endl;
        avlt->cengci_travel();
        cout << "**************??????**********" << endl;
        cout << "?????? " << avlt->height() << endl;
        return 0;
}

Replies to Re: Re: fff rss

Title Name Language When
sdfdsf lichnow c 11 Years ago.