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

📄 gremlin.cc

📁 支持组件模型CCM的开源中间件-mico
💻 CC
字号:
#include <iostream>#include <climits>#include <cstdlib>#include <ctime>using namespace std;intmain (int argc, char *argv[]){    long seed = 0, rounds = 0;    if (argc == 2) {	seed = atoi(argv[1]);    } else if (argc > 2) {	seed = atoi(argv[1]);	rounds = atoi(argv[2]);    }    if (seed <= 0)	seed = time(NULL);    if (rounds <= 0)	rounds = LONG_MAX;    srand(seed);    int limits[] = { 5 /* invoke */, 13 /* delay */, 16 /* handoff */,		     18 /* recovery */ };    int last = limits[3];    int abno = 2;    for (long i = 0; i < rounds; ++i) {	int choice = rand() / (RAND_MAX / last + 1);	if (choice < limits[0]) {	    cout << "invoke ";	    int which = rand() / (RAND_MAX / 2 + 1);	    if (which == 0)		cout << "net ";	    else		cout << "term ";	    int delay = rand() / (RAND_MAX / 20 + 1);	    delay -= 5;	    if (delay < 0)		delay = 0;	    cout << delay << endl;	} else if (choice < limits[1]) {	    cout << "delay ";	    int delay = rand() / (RAND_MAX / 10 + 1);	    cout << delay + 1 << endl;	} else if (choice < limits[2]) {	    cout << "handoff ";	    int which = rand() / (RAND_MAX / 2 + 1);	    if (which == 0) {		cout << "net ";		int from = rand() / (RAND_MAX / abno + 1);		cout << from << " ";	    } else		cout << "term ";	    int to = rand() / (RAND_MAX / abno + 1);	    cout << to << endl;	} else if (choice < limits[3]) {	    cout << "recovery ";	    int to = rand() / (RAND_MAX / abno + 1);	    cout << to << endl;	}    }    return 0;}

⌨️ 快捷键说明

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