コード例 #1
0
void addB(struct bNode * root, int val){
	if(val<root->val){
		if(root->left==NULL){
			struct bNode * node = malloc(sizeof(struct bNode));
			node->val=val;
			node->left=NULL;
			node->right=NULL;
			root->left=node;
		}
		else{
			addB(root->left,val);
		}
	}

	if(val>root->val){
		if(root->right==NULL){
			struct bNode * node = malloc(sizeof(struct bNode));
			node->val=val;
			node->left=NULL;
			node->right=NULL;
			root->right=node;
		}
		else{
			addB(root->right,val);
		}
	}


}
コード例 #2
0
ファイル: forms.cpp プロジェクト: darwinbeing/Hifi-Pod
FormSetup::FormSetup(QWidget * parent):QWidget(parent)
{
	ui.setupUi(this);
	connect( ui.ApplyB, SIGNAL( clicked() ), this, SLOT( ApplyB() ) );
	connect( ui.addB, SIGNAL( clicked() ), this, SLOT( addB() ) );
	connect( ui.hzB, SIGNAL( valueChanged(int) ), this, SLOT( hz_1() ) );
	connect( ui.hzB_2, SIGNAL( valueChanged(int) ), this, SLOT( hz_2() ) );
	connect( ui.hzB_3, SIGNAL( valueChanged(int) ), this, SLOT( hz_3() ) );
	connect( ui.hzB_4, SIGNAL( valueChanged(int) ), this, SLOT( hz_4() ) );
	connect( ui.hzB_5, SIGNAL( valueChanged(int) ), this, SLOT( hz_5() ) );
	connect( ui.hzB_6, SIGNAL( valueChanged(int) ), this, SLOT( hz_6() ) );
	connect( ui.hzB_7, SIGNAL( valueChanged(int) ), this, SLOT( hz_7() ) );
	connect( ui.hzB_8, SIGNAL( valueChanged(int) ), this, SLOT( hz_8() ) );
	connect( &setupTimer, SIGNAL(timeout()), this, SLOT(FsetupTimer()) );
}
コード例 #3
0
int FormSetup::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: ApplyB(); break;
        case 1: addB(); break;
        case 2: hz_1(); break;
        case 3: hz_2(); break;
        case 4: hz_3(); break;
        case 5: hz_4(); break;
        case 6: hz_5(); break;
        case 7: hz_6(); break;
        case 8: hz_7(); break;
        case 9: hz_8(); break;
        case 10: FsetupTimer(); break;
        default: ;
        }
        _id -= 11;
    }
    return _id;
}
コード例 #4
0
int main(){
	//SINGLEY LINKED LIST
	struct sslNode * head = malloc(sizeof(struct sslNode));
	head -> next=NULL;
	head -> val = 0;	
	addSSL(head,5);
	printf("Success\n");
	addSSL(head,3);
	printf("Success\n");
	addSSL(head,9);
	printf("Success\n");
	printSSL(head);

	//BINARY TREE
	
	int i;
	for(i=0;i<1000;i++){
		bStack[i]=0;
	}



	struct bNode * root = malloc(sizeof(struct bNode));
	root->left=NULL;
	root->right=NULL;
	/*root->val=5;
	addB(root,3);
	addB(root,6);
	addB(root,9);
	addB(root,4);
    */
    /*
    root->val=1;
    addB(root,2);
	addB(root,3);
	addB(root,4);
	*/
    root->val=4;
    addB(root,3);
    addB(root,5);
	addB(root,1);
	addB(root,7);
    //addB(root,4);

    setStack(root,0);

	printf("The number of nodes is %d\n",numNodes);
	height=floor(log(numNodes)/log(2));
	printf("The height of this tree is %d\n",height);
	int offset=pow(2,height);
	printf("The offset is %d\n",offset);
	
	printStack(0,offset);
	printf("\n");

	int array[5] = {1,2,3,5,4};
	int * pointer;
	pointer= &array[2];
	arrayPrinter(pointer,array);
	pointer= &array[0];
	arrayPrinter(pointer,array);
	pointer= &array[4];
	arrayPrinter(pointer,array);
	pointer= &array[5];
	arrayPrinter(pointer,array);



}