zoukankan      html  css  js  c++  java
  • 贝叶斯网络 未学习前数据结构

    /**
    author: lx
    date 4.11 2011
    biref BN
    */

    #pragma once
    #include
    <string>
    #include
    <map>
    #include
    <vector>
    #include
    <iostream>
    using namespace std;

    typedef pair
    < char, float > inter;

    /* struct of node */
    struct nbnode
    {
    char name[20]; /* name */

    vector
    < inter > nodeprob; /* probility of each node */

    };

    void print_nbnode( struct nbnode* node )
    {
    cout
    << "name is " << node->name << endl;

    int i;
    for ( i = 0; i < (node->nodeprob).size(); i++ )
    {
    cout
    << (node->nodeprob)[i].first << " is " << (node->nodeprob)[i].second << endl;
    }
    }


    #include "rbnetwork.h"
    #include
    <stdlib.h>
    #include
    <string.h>
    #include
    <stdio.h>
    #include
    <iostream>
    #include
    <list>
    #include
    <algorithm>
    using namespace std;

    int main( void )
    {
    int n;
    list
    < struct nbnode* > listnode;

    cout
    << "请输入参数个数!" << endl;
    cin
    >> n;

    int i;
    for ( i = 0; i < n; i++ )
    {
    struct nbnode* node = ( struct nbnode* )malloc( sizeof(struct nbnode ) );
    switch( i )
    {
    case 0:
    {
    strcpy( node
    ->name, "a" );

    inter int1, int2;
    int1.first
    = 'f';
    int1.second
    = 0.4f;
    int2.first
    = 't';
    int2.second
    = 0.6f;

    (node
    ->nodeprob).push_back( int1 );
    (node
    ->nodeprob).push_back( int2 );
    listnode.push_back( node ); }
    break;

    case 1:
    {
    strcpy( node
    ->name, "b" );

    inter int1, int2;
    int1.first
    = 'f';
    int1.second
    = 0.5f;
    int2.first
    = 't';
    int2.second
    = 0.5f;

    (node
    ->nodeprob).push_back( int1 );
    (node
    ->nodeprob).push_back( int2 ); listnode.push_back( node );
    }
    break;

    case 2:
    {
    strcpy( node
    ->name, "c" );

    inter int1, int2;
    int1.first
    = 'f';
    int1.second
    = 0.3f;
    int2.first
    = 't';
    int2.second
    = 0.7f;

    (node
    ->nodeprob).push_back( int1 );
    (node
    ->nodeprob).push_back( int2 ); listnode.push_back( node );
    }
    break;

    case 3:
    {
    strcpy( node
    ->name, "d" );

    inter int1, int2;
    int1.first
    = 'f';
    int1.second
    = 0.1f;
    int2.first
    = 't';
    int2.second
    = 0.9f;

    (node
    ->nodeprob).push_back( int1 );
    (node
    ->nodeprob).push_back( int2 ); listnode.push_back( node );
    }
    break;


    default:
    break;
    }

    }
    for_each ( listnode.begin(), listnode.end(), print_nbnode );
    cout
    << endl;

    return 0;
    }

  • 相关阅读:
    全新通用编程语言 Def 招募核心贡献者、文档作者、布道师 deflang.org
    全球最快的JS模板引擎:tppl
    4行代码实现js模板引擎
    [Node.js框架] 为什么要开发 Codekart 框架
    Android用BusyBox替换系统toolbox
    纪念一下,昨天换手机了
    在Android上使用gcc编译C/C++源程序
    关于BAPI_ACC_DOCUMENT_POST解读
    关于ABAP和JSON互相转换
    关于客户和供应商预制凭证添加WBS字段
  • 原文地址:https://www.cnblogs.com/lxgeek/p/2012821.html
Copyright © 2011-2022 走看看