科幻程序集

张宸琳

2022-08-16 11:14:19

Personal

[这是我的另一份程序集](https://www.luogu.com.cn/blog/zhangchenlin2009/amazing-cpp) 确实,我编的科幻程序(以三体为主)的数量已经可以单独开一份程序集了 再送上[科幻迷们的题单](https://www.luogu.com.cn/training/111307) > 注:建议将程序复制到 Dev-C++ 中编译 *** * 三体-幽灵倒计时 * 三体-飞蚊症 * 科幻-诗云 * 科幻-电子诗人 * 星球大战-原力测试器 * 三体-歌者 * 三体-黑暗森林模拟器 *** ## 三体-幽灵倒计时 ``` #include<bits/stdc++.h> #include<windows.h> #include<cstdlib> using namespace std; string s[10][5]={ " ### ", "# # ", "# # ", "# # ", " ### ", " # ", " ## ", " # ", " # ", "##### ", " ### ", "# # ", " # ", " ## ", "##### ", " ### ", "# # ", " ## ", "# # ", " ### ", " # ", " ## ", " # # ", "##### ", " # ", "##### ", "# ", "#### ", " # ", "#### ", " ### ", "# ", "#### ", "# # ", " ### ", "##### ", " # ", " # ", " # ", " # ", " ### ", "# # ", " ### ", "# # ", " ### ", " ### ", "# # ", " ### ", " # ", " # "}; string str[5]={ " ", "# ", " ", "# ", " "}; int main() { int a=1200,b=0,c=0,d=0; while(1) { printf("\n\n\n\n\n\n\n\n\n\n"); for(int i=0;i<5;i++) { printf("\n\t\t"); cout<<s[a/1000][i]<<s[a/100%10][i]<<s[a/10%10][i]<<s[a%10][i]<<str[i]<<s[b/10][i]<<s[b%10][i]<<str[i]<<s[c/10][i]<<s[c%10][i]<<str[i]<<s[d/10][i]<<s[d%10][i]; } d--; if(d<0) { c--; d=59; if(c<0) { b--; c=59; if(b<0) { a--; b=59; } } } Sleep(1000); system("cls"); } return 0; } ``` ## 三体-飞蚊症 ``` #include<bits/stdc++.h> #include<windows.h> using namespace std; int main() { int x,y,i; srand(time(NULL)); while(1) { x=rand()%10; y=rand()%110; for(i=1;i<=10;i++) { cout<<endl; if(i==x) { for(int j=0;j<=y;j++) cout<<' '; cout<<"*"; } } } return 0; } ``` ## 科幻-诗云 [学而思编程社区发布链接](https://code.xueersi.com/home/project/detail?lang=code&pid=35046016&version=cpp&form=cpp&langType=cpp) ``` #include <bits/stdc++.h> using namespace std; int main() { int ran,n; srand(time(0)); cout<<"诗云1.0程序已开始运行,请输入你希望创作的诗歌数:"; cin>>n; system("cls"); while(n) { for(int k=0;k<=1;k++) { ran=rand()%2; if(ran==0) { for(int i=0;i<2;i++) { ran=rand()%36; int ran1=ran; if(ran==0) cout << "春燕"; else if(ran==1) cout << "雨新"; else if(ran==2) cout << "柳枝"; else if(ran==3) cout << "后庭"; else if(ran==4) cout << "明月"; else if(ran==5) cout << "月明"; else if(ran==6) cout << "松林"; else if(ran==7) cout << "竹林"; else if(ran==8) cout << "江天"; else if(ran==9) cout << "华山"; else if(ran==10) cout << "江雪"; else if(ran==11) cout << "江山"; else if(ran==12) cout << "银河"; else if(ran==13) cout << "朝霞"; else if(ran==14) cout << "晚霞"; else if(ran==15) cout << "洛江"; else if(ran==16) cout << "流水"; else if(ran==17) cout << "桨晨"; else if(ran==18) cout << "舷窗"; else if(ran==19) cout << "轩窗"; else if(ran==20) cout << "白鹭"; else if(ran==21) cout << "渔翁"; else if(ran==22) cout << "归客"; else if(ran==23) cout << "貂裘"; else if(ran==24) cout << "石栈"; else if(ran==25) cout << "玉饮"; else if(ran==26) cout << "萧鼓"; else if(ran==27) cout << "红霞"; else if(ran==28) cout << "落日"; else if(ran==29) cout << "白桦"; else if(ran==30) cout << "夕阳"; else if(ran==31) cout << "孤舟"; else if(ran==32) cout << "破桥"; else if(ran==33) cout << "牛郎"; else if(ran==34) cout << "织女"; else if(ran==35) cout << "天河"; else if(ran==35) cout << "星光"; ran=rand()%16; if(ran==0) cout << "归"; else if(ran==1) cout << "照"; else if(ran==2) cout << "映"; else if(ran==3) cout << "入"; else if(ran==4) cout << "沉"; else if(ran==5) cout << "离"; else if(ran==6) cout << "留"; else if(ran==7) cout << "别"; else if(ran==8) cout << "送"; else if(ran==9) cout << "过"; else if(ran==10) cout << "绎"; else if(ran==11) cout << "梦"; else if(ran==12) cout << "思"; else if(ran==13) cout << "望"; else if(ran==14) cout << "听"; else if(ran==15) cout << "闻"; ran=rand()%36; while(ran1==ran) ran=rand()%36; if(ran==0) cout << "春燕"; else if(ran==1) cout << "雨新"; else if(ran==2) cout << "柳枝"; else if(ran==3) cout << "后庭"; else if(ran==4) cout << "明月"; else if(ran==5) cout << "月明"; else if(ran==6) cout << "松林"; else if(ran==7) cout << "竹林"; else if(ran==8) cout << "江天"; else if(ran==9) cout << "华山"; else if(ran==10) cout << "江雪"; else if(ran==11) cout << "江山"; else if(ran==12) cout << "银河"; else if(ran==13) cout << "朝霞"; else if(ran==14) cout << "晚霞"; else if(ran==15) cout << "洛江"; else if(ran==16) cout << "流水"; else if(ran==17) cout << "桨晨"; else if(ran==18) cout << "舷窗"; else if(ran==19) cout << "轩窗"; else if(ran==20) cout << "白鹭"; else if(ran==21) cout << "渔翁"; else if(ran==22) cout << "归客"; else if(ran==23) cout << "貂裘"; else if(ran==24) cout << "石栈"; else if(ran==25) cout << "玉饮"; else if(ran==26) cout << "萧鼓"; else if(ran==27) cout << "红霞"; else if(ran==28) cout << "落日"; else if(ran==29) cout << "白桦"; else if(ran==30) cout << "夕阳"; else if(ran==31) cout << "孤舟"; else if(ran==32) cout << "破桥"; else if(ran==33) cout << "牛郎"; else if(ran==34) cout << "织女"; else if(ran==35) cout << "天河"; else if(ran==35) cout << "星光"; cout << endl; } } else { int ran1,ran2; for(int i=0;i<2;i++) { ran=rand()%7; while(ran2==ran) ran=rand()%7; ran2=ran; if(ran==0) cout << "绕步"; else if(ran==1) cout << "别下"; else if(ran==2) cout << "听闻"; else if(ran==3) cout << "留上"; else if(ran==4) cout << "节落"; else if(ran==5) cout << "信罢"; else if(ran==6) cout << "步升"; ran=rand()%10; while(ran1==ran) ran=rand()%10; ran1=ran; if(ran==0) cout << "独夜行"; else if(ran==1) cout << "一夜惊"; else if(ran==2) cout << "知天命"; else if(ran==3) cout << "有情人"; else if(ran==4) cout << "双飞翼"; else if(ran==5) cout << "离殇人"; else if(ran==6) cout << "过前堂"; else if(ran==7) cout << "竹林晚"; else if(ran==8) cout << "绵青延"; else if(ran==9) cout << "一灯明"; else if(ran==10) cout << "独行人"; cout << endl; } } } cout<<endl; n--; } return 0; } ``` ## 科幻-电子诗人 [学而思编程社区发布链接](https://code.xueersi.com/home/project/detail?lang=code&pid=35116577&version=cpp&form=cpp&langType=cpp) ``` #include<bits/stdc++.h> #include<windows.h> #define clean(); system("cls"); using namespace std; string word1[20]={"归","照","映","入","沉","离","留","别","送","过","绎","梦","思","望","听","闻","忆","知","识"}; string word2n[50]={"春燕","新雨","柳枝","后庭","明月","月明","松林","竹林","江天","华山","江雪","江山","银河","朝霞","晚霞","洛江","流水","桨晨","舷窗","轩窗","白鹭","渔翁","归客","貂裘","石栈","玉饮","萧鼓","红霞","落日","白桦","夕阳","孤舟","破桥","牛郎","织女","天河","星光","天命","前堂","汗青","寰宇","星海","横流","暗夜","霞光","彩霞"}; string word2v[20]={"绕步","别下","听闻","留落","节落","信罢","步升","飞旋","仰望","独思","怀想"}; string word3[20]={"独夜行","一夜惊","有情人","双飞翼","离殇人","竹林晚","绵青延","一灯明","暗行人","执剑人","新月明","守墓人"}; int mod1=19,mod2n=46,mod2v=11,mod3=12; int main() { int ran,kind,turn,con; srand(time(0)); cout<<"电子诗人1.0加载中"; for(int i=1;i<=50;i++) { Sleep(20); cout<<"."; } cout<<"\n电子诗人1.0程序已启动\n"; Sleep(1500); do { clean(); cout<<"如果你想了解此程序的背景,请在下方输入0\n"; cout<<"目前支持以下几类诗歌创作:\n1.五言绝句\n2.五言律诗\n3.七言绝句\n4.七言律诗\n"; cout<<"请输入你希望创作的诗歌类型(输入0为程序背景):"; cin>>kind; clean(); if(kind==0) { string s1="注:从此作品起,原本的诗云系列将会分裂为两个系列,分别为诗云系列和电子诗人系列。\n诗云系列将会着重文字的随机,贴合《诗云》小说中的诗歌写作器\n电子诗人系列将会着重诗歌的对仗,押韵等,使其能成为真正的“诗歌”。"; string s2="电子诗人1.0简介\n《电子诗人》是刘慈欣的一篇科幻随笔,发表于水木清华社区。他利用电脑创作现代诗歌,选了几首发表出来。随后因此想法而创作了小说《诗云》。\n电子诗人系列尝试把此诗歌创作过程还原出来,但由于本程序员时间与技术均有限,无法做到与原版一样。目前仅限于古诗,宋词与元曲均无法实现,现代诗创作更加艰难,我只能尽力而为。\n为了加快系列创作整体速度,两个系列都会开放源代码,欢迎各位改编(改编好的可能还会成为我下一个版本的基础哦~)\n"; for(int i=0;i<s1.size();i++) { cout<<s1[i]; Sleep(40); } cout<<endl<<endl; Sleep(1000); for(int i=0;i<s2.size();i++) { cout<<s2[i]; Sleep(40); } } else if(kind==1||kind==2) { if(kind==1) turn=2; else turn=4; for(int j=1;j<=turn;j++) { ran=rand()%2; if(ran==0) { int ran1; for(int i=0;i<2;i++) { ran=rand()%mod2n; ran1=ran; cout<<word2n[ran]; ran=rand()%mod1; cout<<word1[ran]; ran=rand()%mod2n; while(ran1==ran) ran=rand()%mod2n; cout<<word2n[ran]<<endl; } } else { int ran1; for(int i=0;i<2;i++) { ran=rand()%mod2v; ran1=ran; cout<<word2v[ran]; ran=rand()%mod3; while(ran1==ran) ran=rand()%mod3; ran1=ran; cout<<word3[ran]<<endl; } } } } else { if(kind==3) turn=2; else turn=4; for(int j=1;j<=turn;j++) { ran=rand()%2; if(ran==0) { for(int i=0;i<2;i++) { ran=rand()%mod2n; cout<<word2n[ran]; ran=rand()%mod2v; cout<<word2v[ran]; ran=rand()%mod3; cout<<word3[ran]<<endl; } } else { int ran1; for(int i=0;i<2;i++) { ran=rand()%mod2n; ran1=ran; cout<<word2n[ran]; ran=rand()%mod2n; while(ran1==ran) ran=rand()%mod2n; cout<<word2n[ran]; ran=rand()%mod1; cout<<word1[ran]; ran=rand()%mod2v; cout<<word2n[ran]<<endl; } } } } cout<<"---------------------------------------\n"; cout<<"是否继续诗歌创作?\n1.是 2.否\n"; cin>>con; }while(con==1); clean(); cout<<"欢迎下次使用电子诗人1.0!我将会为你献上最独特也最搞笑的诗歌!\n(一张大大的笑脸)"; return 0; } ``` ## 星球大战-原力测试器 [星球大战中文网发布链接](http://starwarschina.com/thread-46966-1-1.html) ``` #include<bits/stdc++.h> #include<cstdlib> using namespace std; int main() { srand(time(NULL)); int test,score=0; int s1,s2; bool flag=1; string s; cout<<"原力测试器(简化版)\n"; cout<<"0.程序简介/背景故事\n"; cout<<"1.直接开始\n"; cin>>test; if(test==0) { system("cls"); cout<<"声明:本程序的编者是个初中生,只看了正传三部曲和前传三部曲外加Jedi Path(英文原版),所以下方的叙述中如果有错请见谅。对于程序本身有什么可以改进的地方,欢迎在评论区留言。 \n"; cout<<"【这不是一个游戏,请认真对待】 \n\n"; cout<<"在Jedi Path中,Jedi Initiate阶段只训练感知能力,也就是Luke在千年隼号上受到的训练。而何时能够通过肢体动作来移动物体则没有说明,但在Jedi Master阶段有提到完全靠意念移动物体。\n"; cout<<"然而在电影中,很明显发现在Padawan阶段已经可以隔空移物了(Anakin原力送水果的经典画面)。\n"; cout<<"(合理推测)我相信,肯定有国外或国内的星战迷去试过通过冥想(meditation)来感知原力,尽管我本人试了半个月没有明显感受 \n"; cout<<"如何快速判断一个人是不是力敏(假如力敏真的存在)?电影中,可以通过测量纤原体(midi-chlorian)指数的方式来得知,但目前没有这个技术水平,也没有人真的了解纤原体到底长什么样。甚至我怀疑纤原体这个设定是有漏洞的。\n"; cout<<"也有人(比如我同学)尝试直接隔空移物。但很明显,这不是一种好方法。\n"; cout<<"回归原文,Jedi Inititate阶段就已经有感知能力(sense ability),所以最好的测试方式应该是测感知能力,前传1中Anakin做的测试便是测试感知能力。\n"; cout<<"当然,现在没有真正的光剑,也没有反重力训练球。不过可以干一件事:猜数字/答案。本程序所提供的便是这种测试方式。\n"; cout<<"我提供了多种模式,从心理角度和客观选择考虑,可以自行选择搭配模式,总共有6种(a1,a2,b1,b2,c1,c2)\n"; cout<<"从理论上来说,应该还得有更多模式,但这只是个简化版,而且这种测试本就不应该太繁复。编者的程序能力也有限,不可能搞太复杂的,比如图片测试就无法做出来。\n"; cout<<"在发布之前,我已经做过数十次测试。*1模式如果随机打准确率大约在40%左右(很不可思议,竟然不是50%)。如果*1模式得分通常在70%以上,基本就可以算作是现代的力敏了,要求也不能太高。考试时选择题不会做猜一下也八九不离十(doge\n"; cout<<"May the Force be with you.\n"; cout<<"\n"; cout<<"按下1开始测试\n"; char c; cin>>c; } while(flag) { system("cls"); cout<<"代号解释\na:答完一点告知正确与否,且不清屏\nb:答完一点不告知结果,不清屏\nc:答完一点不告知结果,清屏\n"<<endl; cout<<"1:两种数字01\n2:四种字符ABCD\n"<<endl; cout<<"请输入版本代号(字母字符在前,数字字符在后):"<<endl; cin>>s; if(s[0]=='a')//不清屏 s1=1; else if(s[0]=='b')//不显示结果 s1=2; else //清屏 s1=3; if(s[1]=='1')//0 1 s2=1; else //ABCD s2=2; cout<<"请输入测试点数量(回车后直接开始,无提示语):"<<endl; cin>>test; score=0; if(s1==3) system("cls"); for(int t=1;t<=test;t++) { int ans,f; char c; if(s2==1) { ans=rand()%2; cin>>f; } else { ans=rand()%4+'A'; cin>>c; } if(f==ans||c==ans) { if(s1==1) cout<<"right\n"; score++; } else if(s1==1) cout<<"wrong\n"; if(s1==3) system("cls"); } cout<<"你的成绩:"<<score<<'/'<<test; cout<<"\n-------------------------------------------"; cout<<"\n是否再来一次?1:是 0:否\n"; cin>>flag; } return 0; } ``` ## 三体-歌者 > 这是一个做歌者短动画的程序,灵感来源于 [http://www.asciimation.co.nz/#](http://www.asciimation.co.nz/#)(没错,这是一个星战的东西) > > 由于此代码过长,就不放出来了,想要看源码着请私信邮箱号,我会发给你 > > (我编过的最长的一份代码,三千多行……尽管大多数内容都是复制的) ## 三体-黑暗森林模拟器 [三体社区发布链接](https://eto.st1379.com/forum.php?mod=viewthread&tid=6844)(内含源码及样例输入输出,支持提供输入数据后我来测试) ``` /* noc==0 --> dan<5 5<dan<8 rand dan>8 true sci<=5 原始时代 5<sci<=15 科学时代 15<sci<=30 核能时代 30<sci<=45 星舰时代 45<sci<=60 微观时代 60<sci<=80 曲率时代 80<sci<=100 光粒/奇点炸弹时代 sci>100 归零时代 */ #include<bits/stdc++.h> using namespace std; const int SIZE=105; struct Node { int killer; int t,x; }; struct happen { int a,b; int x,t; int way;//-1战争 0交流 1二向箔 2光粒 3奇点炸弹 4光墓 }; struct civ { bool alive; int x;//坐标 int start;//诞生时间 double sci;//技术值 double b,bb;//技术爆炸指数 int dan;//危险指数 bool hide;//是否建造黑域 bool kill;//需要用二向箔清理否 int star;//是否成为星际文明及速度 vector<int> hunt;//发现了谁 }; civ c[SIZE]; Node q[SIZE*SIZE]; happen h[SIZE*SIZE]; int st=0,ed=0,head=0,tail=0,Time; bool f[SIZE][SIZE],ff[SIZE][SIZE],clam[SIZE][SIZE],kill[SIZE][SIZE],talk[SIZE][SIZE]; bool KILL(int a,int b)//a毁灭b { if(c[a].sci>100&&c[b].kill&&c[b].star==0) { printf("%d号文明向%d号文明发射了二向箔\n",a,b); kill[a][b]=1; h[tail]=(happen){a,b,c[a].x,Time,1}; tail++; return 1; } else if(c[a].sci>80&&!c[b].kill&&c[b].star==0) { if(rand()%2==0) { printf("%d号文明向%d号文明发射了光粒\n",a,b); h[tail]=(happen){a,b,c[a].x,Time,2}; tail++; } else { printf("%d号文明向%d号文明发射奇点炸弹\n",a,b); h[tail]=(happen){a,b,c[a].x,Time,3}; tail++; } kill[a][b]=1; return 1; } else if(c[a].sci>60&&c[b].sci<=30&&!c[b].kill&&rand()%3==0&&c[a].star!=0) { h[tail]=(happen){a,b,c[a].x,Time,4}; tail++; kill[a][b]=1; printf("%d号文明向%d号文明的方向驶去\n",a,b); if(c[a].x>c[b].x) c[a].star=-1; else c[a].star=1; return 1; } return 0; } int main() { bool flag; srand(time(0)); freopen("test.in","r",stdin); freopen("test.out","w",stdout); int n; Time=0; cin>>n; for(int i=1;i<=n;i++) { //输入信息:诞生时间,技术爆炸指数,危险指数,需要用二向箔清理否,坐标 cin>>c[i].start>>c[i].b>>c[i].bb>>c[i].dan>>c[i].kill>>c[i].x; c[i].alive=1; c[i].sci=0; } int num=n,len=0; while(num>1) { Time++; flag=0; while(len<n&&c[len+1].start==Time) { len++; flag=1; printf("%d号文明诞生\n",len); } if(rand()%(100/len)==0&&len>1)//文明被发现 { int a=rand()%len+1,tri=1; while((c[a].sci<=5||!c[a].alive||c[a].hide)&&tri<10) { a=rand()%len+1; tri++; } if(tri<10) { tri=1; int b=rand()%len+1; while((c[b].sci<=5||!c[b].alive||c[b].hide||a==b)&&tri<10) { b=rand()%len+1; tri++; } if(tri<10&&!ff[a][b]) { ff[a][b]=1; c[a].hunt.push_back(b); flag=1; printf("%d号文明发现%d号文明\n",a,b); } } } for(int i=head;i<tail;i++) { if(!c[h[i].a].alive||c[h[i].a].hide) continue; if(!c[h[i].b].alive||c[h[i].b].hide) continue; if(h[i].way==-1) { if(c[h[i].a].x==c[h[i].b].x) c[h[i].a].star=c[h[i].b].star; if(rand()%5==0) { if(c[h[i].a].sci-c[h[i].b].sci>rand()%3+5) { printf("%d号文明在战争中获胜,%d号文明毁灭\n",h[i].a,h[i].b); flag=1; c[h[i].b].alive=0; } else if(c[h[i].b].sci-c[h[i].a].sci>rand()%3+5) { printf("%d号文明在战争中获胜,%d号文明毁灭\n",h[i].b,h[i].a); flag=1; c[h[i].a].alive=0; } } } else if(h[i].way==4) { if(c[h[i].a].x==c[h[i].b].x&&c[h[i].b].star==0) { printf("%d号文明将%d号文明的星系改造成光墓,%d号文明再也无法逃出\n",h[i].a,h[i].b,h[i].b); flag=1; c[h[i].b].hide=1; c[h[i].b].b=0; } } else if(abs(h[i].x-c[h[i].b].x)==Time-h[i].t) { if(h[i].way==0) { if(!ff[h[i].b][h[i].a]) { ff[h[i].b][h[i].a]=1; c[h[i].b].hunt.push_back(h[i].a); flag=1; printf("%d号文明接收到了%d号文明的信息,得知%d号文明的存在\n",h[i].b,h[i].a,h[i].a); } } else if(h[i].way==1&&c[h[i].b].star==0) { printf("%d号文明发射的二向箔抵达%d号文明的星系,%d号文明成为了宇宙中的一幅画\n",h[i].a,h[i].b,h[i].b); flag=1; c[h[i].b].alive=0; } else if(h[i].way==2&&c[h[i].b].star==0) { printf("%d号文明发射的光粒抵达%d号文明的星系,%d号文明在恒星的爆炸中毁灭\n",h[i].a,h[i].b,h[i].b); flag=1; c[h[i].b].alive=0; } else if(h[i].way==3&&c[h[i].b].star==0) { printf("%d号文明发射的奇点炸弹抵达%d号文明的星系,%d号文明被吸入黑洞\n",h[i].a,h[i].b,h[i].b); flag=1; c[h[i].b].alive=0; } } } while((!c[h[head].b].alive||c[h[head].b].hide)&&(head<tail)) head++; for(int i=1;i<=len;i++) { if(!c[i].alive) continue; if(c[i].hide) continue; c[i].sci+=c[i].b; c[i].b*=(1.0+c[i].bb); c[i].x+=c[i].star; if(c[i].sci>30&&rand()%20==0&&c[i].star==0)//星舰文明 { if(rand()%2==0) c[i].star=1; else c[i].star=-1; printf("%d号文明成为星舰文明,游荡在星海中\n",i); flag=1; } if(c[i].dan>8||(c[i].dan>=5&&rand()%3==0))//清理 { for(int j=st;j<ed;j++) if(c[q[j].killer].alive&&q[j].killer!=i&&!c[q[j].killer].hide&&abs(c[i].x-q[j].x)<=Time-q[j].t&&!kill[i][q[j].killer]) { if(KILL(i,q[j].killer)) flag=1; } while(!c[q[st].killer].alive&&st<ed) st++; } for(int j=0;j<c[i].hunt.size();j++) { int befound=c[i].hunt[j]; if(!c[befound].alive||c[befound].hide) continue; if(c[i].dan>8||(c[i].dan>5&&rand()%4==0))//毁灭 { if(!c[befound].star&&!kill[i][befound]) { if(KILL(i,befound)) flag=1; else if(c[i].sci>40&&!f[i][befound]) { q[ed].killer=befound; f[i][befound]=1; ed++; flag=1; printf("%d号文明广播%d号文明的坐标\n",i,befound); } } else if(c[i].star&&c[befound].star) { bool flagg=1; for(int j=head;j<tail;j++) if(h[j].a==i&&h[j].b==befound) { flagg=0; break; } if(flagg) { h[tail]=(happen){i,befound,c[i].x,Time,-1}; tail++; flag=1; printf("%d号文明向%d号文明攻击,一场宇宙战争开始了\n",i,befound); if(c[i].x>c[befound].x) c[i].star=-1; else c[i].star=1; c[befound].star=-c[i].star; } } } else if(c[i].dan<=4&&c[i].sci>20&&(!talk[i][befound]||rand()%20==0))//交流 { talk[i][befound]=1; flag=1; h[tail]=(happen){i,befound,c[i].x,Time,0}; tail++; printf("%d号文明与%d号文明交流\n",i,befound); } /* else//沉默 { if(!clam[i][befound]) { clam[i][befound]=1; flag=1; printf("%d号文明对%d号文明保持了沉默\n",i,befound); } }*/ } if(c[i].sci>60&&!c[i].hide&&c[i].dan>=7&&c[i].dan+rand()%100+rand()%100>=205&&c[i].star==0)//宇宙安全声明 { c[i].hide=1; flag=1; printf("%d号文明为自己建造了黑域,从此与世隔绝\n",i); c[i].b=0; } if(rand()%20==0) c[i].dan++; } num=0; for(int i=1;i<=n;i++) if(c[i].alive&&!c[i].hide) num++; if(flag) printf("\t——第%d世纪记录\n\n",Time); } return 0; } ```