软件工程

本类阅读TOP10

·PHP4 + MYSQL + APACHE 在 WIN 系统下的安装、配置
·Linux 入门常用命令(1)
·Linux 入门常用命令(2)
·使用 DCPROMO/FORCEREMOVAL 命令强制将 Active Directory 域控制器降级
·DirectShow学习(八): CBaseRender类及相应Pin类的源代码分析
·基于ICE方式SIP信令穿透Symmetric NAT技术研究
·Windows 2003网络负载均衡的实现
·一网打尽Win十四种系统故障解决方法
·数百种 Windows 软件的免费替代品列表
·收藏---行百里半九十

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
求Petri网的S-不变量和T-不变量的程序

作者:未知 来源:月光软件站 加入时间:2005-5-13 月光软件站

////求Petri网的S-不变量和T-不变量的程序,给出的是求T不变量的,求S-不变量只需要将矩阵转置。Petri网

/////经常用于通信和网络协议的验证,但是直接由矩阵求不变量非常麻烦,故本文将代码共享。

#include <iostream.h>
#include <math.h>

int main()
{
 
 int row,column;
 int matrix[50][50];    ////Petri网关联矩阵
 int answer[50];       ///求得的不变量

 cout << "please input the row num of matrix:" ;
    cin >> row;
 cout << "please input the column num of matrix:" ;
 cin >> column;
    cout << "please input information of matrix:" << endl;
 for(int i=0;i<row;i++)
 {
  for(int j=0;j<column;j++)
  {
   cin >> matrix[i][j];
  }
 }
 
long power=pow(2,column);
        
int total[50];

 for(i=1;i<power;i++)
 {
  for(int j=0;j<column;j++)
  {
   answer[j]=(i>>j)&0x01;   
  }

  for(int x=0;x<row;x++)
  {
   total[x]=0;
   for(int y=0;y<column;y++)
   {
    total[x]+=answer[y]*matrix[x][y];
   }
   if(total[x]!=0)
    break; 
  }
          
  if(x==row)
  {
   cout << "get a column sequence:" << endl;
   for(x=0;x<column;x++)
   {
    cout << answer[x] << " ";
   }
   cout << endl;
  }

 } 

}

月影孤鸿 华中科技大学计算机学院  [email protected]




相关文章

相关软件