⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 banetworks.cpp

📁 该程序可以生成无标度网络
💻 CPP
字号:
# include <stdio.h>
# include <stdlib.h>
# include <time.h>
# include <math.h>
# include <iostream>
using namespace std;
# define SIZE 3000
char extern a[SIZE][SIZE]={0}; 
main()
{ 
 int i;
 int j;
 int c,d,f;

 /*依次增加一个节点构建无标度网络*/
 for(i=3;i<SIZE;i++)
 {
	 srand( time (NULL) );
     c=rand() % i;
     a[i][c]=a[c][i]=1; 
	
 do
 {
	 srand( time (NULL) );
     d=rand() % i;
 }
  while(c==d);
  a[i][d]=a[d][i]=1;
 do
{
	 srand( time (NULL) );
     f=rand() % i;
 }
  while(f==d||f==d);
  a[i][f]=a[f][i]=1;
  printf("i为%d时这个随机数为:%d, %d,%d; ",i,c,d,f  );
  }
 for(i=0;i<SIZE;i++)
 { printf("\n");
 for(j=0;j<SIZE;i++)
 {printf("%d",a[i][j]);
 }
 }
 system("pause");
 return(a[SIZE][SIZE]);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -