/**
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;
}