赞
踩
其实也蛮简单的, 几个小时就做完了
一共四百行,全是基础代码,欢迎大佬来优化orz
- #include<bits/stdc++.h>
- #include<Windows.h>
- #define cls system("cls")
- #define wait Sleep(800)
- #define wait1 Sleep(1000)
- #define stop system("pause")
- using namespace std;
- char p[13]={' ','A','2','3','4','5','6','7','8','9','J','Q','K'};
- string s1="好运留下来——",s2="烦恼丢出去!";
- int l=12,name,hide,n=8,nanbei,nannv;
- struct stu{
- int num,f;//点数
- string s;
- }a[20],b[20],ts[20];
- void pp(){//输出藏牌
- cout<<"藏牌:"<<p[hide]<<endl;
- }
- void print(){
- for(int i=1;i<=n;i++) cout<<p[a[i].num]<<endl;
- }
- void FirstStep(){
- for(int i=1;i<=4;i++){
- Sleep(800);
- srand((unsigned)time(NULL));
- int t=rand()%l+1;
- a[i].num=t;
- a[i].f=1;
- a[i+4].num=t;
- a[i+4].f=0;
- cout<<p[t]<<endl;
- }
- stop;
- cls;
- }
- void SecondStep(){
- cout<<"第二步~对折,撕!\n";
- for(int i=1;i<=4;i++){
- wait;
- cout<<p[a[i].num]<<' ';
- wait;
- cout<<p[a[i].num]<<endl;
- }
- wait;
- cls;
- cout<<"第二步~将撕好的牌放在下面\n";
- wait;
- for(int i=1;i<=8;i++){
- cout<<p[a[i].num]<<endl;
- wait;
- }
- stop;
- cls;
- }
- void ThirdStep(){
- cout<<"第三步~问问你的名字有几个字(填数字):";
- cin>>name;
- wait;
- cls;
- cout<<"第三步~将"<<name<<"张牌依次放到下面\n";
- wait;
- print();
- wait1;
- for(int i=1;i<=name;i++){
- cls;
- cout<<"第三步~将"<<name<<"张牌依次放到下面(第"<<i<<"张)\n\n";
- cout<<p[a[2].num]<<" "<<p[a[1].num]<<endl;
- for(int j=3;j<=8;j++) cout<<p[a[j].num]<<endl;
- wait1;
- cls;
- cout<<"第三步~将"<<name<<"张牌依次放到下面(第"<<i<<"张)\n\n";
- for(int j=2;j<=8;j++) cout<<p[a[j].num]<<endl;
- cout<<p[a[1].num];
- wait1;
- cls;
- cout<<"第三步~将"<<name<<"张牌依次放到下面(第"<<i<<"张)\n";
- for(int j=1;j<=8;j++) b[j]=a[j];
- for(int j=1;j<=7;j++) a[j]=b[j+1];
- a[8]=b[1];
- print();
- wait1;
- }
- stop;
- cls;
- }
- void FourthStep(){
- cout<<"第四步~将最上面的三张牌插到中间\n";
- wait;
- print();
- wait1;
- cls;
- cout<<"第四步~请选择您的心仪位置(填对应字母)\n";
- char t='a';
- for(int i=1;i<=3;i++) cout<<p[a[i].num]<<endl;
- for(int i=4;i<8;i++){
- cout<<p[a[i].num]<<endl;
- cout<<' '<<t<<endl;
- t++;
- }
- cout<<p[a[8].num]<<endl;
- wait;
- cout<<"请选择:";
- cin>>t;//a:4.5之间 b:5.6之间 c:6.7之间 d:7.8之间
- wait;//a对应97
- cls;
- cout<<"第四步~将最上面的三张牌插到中间\n";
- int q=t-93,j=1;
- for(int i=4;i<=q;i++){
- cout<<p[a[i].num];
- cout<<endl;
- }
- for(int i=1;i<=3;i++){
- cout<<" "<<p[a[i].num]<<endl;
- }
- for(int i=q+1;i<=8;i++){
- cout<<p[a[i].num]<<endl;
- }
- wait1;
- cls;
- cout<<"第四步~将最上面的三张牌插到中间\n";
- for(int i=1;i<=8;i++) b[i].num=a[i].num;
- for(int i=4;i<=q;i++,j++) a[j].num=b[i].num;
- for(int i=1;i<=3;i++,j++) a[j].num=b[i].num;
- print();
- stop;
- cls;
- }
- void FifthStep(){
- cout<<"第五步~将第一张牌藏到其它地方\n";
- wait;
- print();
- wait;
- cls;
- cout<<"第五步~将第一张牌藏到其它地方\n";
- hide=a[1].num;
- cout<<" "<<p[hide]<<endl;
- for(int i=1;i<=8;i++) b[i].num=a[i].num;
- for(int i=2;i<=8;i++) a[i-1].num=b[i].num;
- n=7;
- print();
- wait;
- cls;
- cout<<"第五步~将第一张牌藏到其它地方\n";
- cout<<p[a[1].num]<<" "<<p[hide]<<endl;
- for(int i=2;i<=7;i++) cout<<p[a[i].num]<<endl;
- wait;
- cls;
- cout<<"第五步~将第一张牌藏到其它地方\n";
- print();
- wait;
- cls;
- cout<<endl;
- cout<<"第五步~将第一张牌藏到其它地方\n";
- print();
- wait;
- cls;
- pp();
- cout<<"第五步~将第一张牌藏到其它地方\n";
- print();
- stop;
- cls;
- }
- void SixthStep(){
- pp();
- cout<<"第六步~你是...南方人填1,北方人填2,不确定填3:";
- cin>>nanbei;
- wait;
- cls;
- pp();
- cout<<"第六步~将最上面的"<<nanbei<<"张牌插到中间\n";
- wait;
- cout<<"请选择心仪的位置(填对应字母)\n";
- wait;
- char t='a';
- for(int i=1;i<=nanbei;i++) cout<<p[a[i].num]<<endl;
- for(int i=nanbei+1;i<=6;i++){
- cout<<p[a[i].num]<<endl;
- cout<<' '<<t<<endl;
- t++;
- }
- cout<<p[a[7].num]<<endl;
- cout<<"请选择:";
- cin>>t;
- wait;
- cls;
- pp();
- cout<<"Loading...";
- wait1;
- cout<<"完毕!\n";
- wait;
- print();
- wait1;
- cls;
- pp();
- cout<<"Loading...完毕!\n";
- for(int i=1;i<=7;i++) b[i].num=a[i].num;
- int q=t-97+1+nanbei,j=1;
- for(int i=nanbei+1;i<=q;i++,j++) a[j].num=b[i].num;
- for(int i=1;i<=nanbei;i++,j++) a[j].num=b[i].num;
- print();
- stop;
- cls;
- }
- void SeventhStep(){
- pp();
- cout<<"第七步~你是...男生填1,女生填2:";
- cin>>nannv;
- wait;
- cls;
- pp();
- cout<<"第七步~将最上面的"<<nannv<<"张牌撒到空中去!\n";
- print();
- wait1;
- cls;
- pp();
- cout<<"第七步~将最上面的"<<nannv<<"张牌撒到空中去!\n";
- for(int i=1;i<=nannv;i++) cout<<" "<<p[a[i].num]<<endl;
- for(int i=nannv+1;i<=7;i++) cout<<p[a[i].num]<<endl;
- wait1;
- cls;
- pp();
- cout<<"第七步~将最上面的"<<nannv<<"张牌撒到空中去!\n";
- for(int i=1;i<=nannv;i++) cout<<p[a[nannv+i].num]<<" "<<p[a[i].num]<<endl;
- for(int i=nannv+nannv+1;i<=7;i++) cout<<p[a[i].num]<<endl;
- wait1;
- cls;
- pp();
- cout<<"第七步~将最上面的"<<nannv<<"张牌撒到空中去!\n";
- for(int i=1;i<=7;i++) b[i]=a[i];
- for(int i=nannv+1;i<=7;i++) a[i-nannv]=b[i];
- n-=nannv;
- print();
- wait;
- stop;
- cls;
- }
- void EighthStep(){
- ts[1].s="见";
- ts[2].s="证";
- ts[3].s="奇";
- ts[4].s="迹";
- ts[5].s="的";
- ts[6].s="时";
- ts[7].s="刻";
- pp();
- cout<<"第八步~跟我一起念带来幸福的七字真言:见证奇迹的时刻\n";
- cout<<"每念一个字从上面放一张牌下去\n";
- wait;
- print();
- wait1;
- cls;
- for(int i=1;i<=7;i++){
- pp();
- cout<<"第八步~跟我一起念带来幸福的七字真言:见证奇迹的时刻\n";
- cout<<"每念一个字从上面放一张牌下去("<<ts[i].s<<")\n\n";
- cout<<p[a[2].num]<<" "<<p[a[1].num]<<endl;
- for(int j=3;j<=n;j++) cout<<p[a[j].num]<<endl;
- wait;
- cls;
- pp();
- cout<<"第八步~跟我一起念带来幸福的七字真言:见证奇迹的时刻\n";
- cout<<"每念一个字从上面放一张牌下去("<<ts[i].s<<")\n\n";
- for(int j=2;j<=n;j++) cout<<p[a[j].num]<<endl;
- cout<<p[a[1].num];
- wait;
- cls;
- pp();
- cout<<"第八步~跟我一起念带来幸福的七字真言:见证奇迹的时刻\n";
- cout<<"每念一个字从上面放一张牌下去("<<ts[i].s<<")\n";
- for(int j=1;j<=n;j++) b[j]=a[j];
- for(int j=2;j<=n;j++) a[j-1]=b[j];
- a[n]=b[1];
- print();
- wait;
- cls;
- }
- pp();
- cout<<"第八步~跟我一起念带来幸福的七字真言:见证奇迹的时刻\n";
- cout<<"每念一个字从上面放一张牌下去(完毕)\n";
- print();
- stop;
- cls;
- }
- void NinthStep(){
- pp();
- cout<<"第九步~祈福仪式的最后一个环节:\n";
- print();
- wait;
- for(int i=1;n>1;i++){
- cls;
- if(i%2){//好运留下来
- pp();
- cout<<"第九步~祈福仪式的最后一个环节:"<<s1<<endl;
- print();
- wait;
- cls;
- pp();
- cout<<"第九步~祈福仪式的最后一个环节:"<<s1<<endl<<endl;
- cout<<p[a[2].num]<<" "<<p[a[1].num]<<endl;
- for(int j=3;j<=n;j++) cout<<p[a[j].num]<<endl;
- wait;
- cls;
- pp();
- cout<<"第九步~祈福仪式的最后一个环节:"<<s1<<endl<<endl;
- for(int j=2;j<=n;j++) cout<<p[a[j].num]<<endl;
- cout<<p[a[1].num];
- wait;
- cls;
- pp();
- cout<<"第九步~祈福仪式的最后一个环节:"<<s1<<endl;
- for(int j=1;j<=n;j++) b[j]=a[j];
- for(int j=2;j<=n;j++) a[j-1]=b[j];
- a[n]=b[1];
- print();
- wait1;
- }
- else{//烦恼丢出去
- pp();
- cout<<"第九步~祈福仪式的最后一个环节:"<<s2<<endl;
- print();
- wait;
- cls;
- pp();
- cout<<"第九步~祈福仪式的最后一个环节:"<<s2<<endl<<endl;
- cout<<p[a[2].num]<<" "<<p[a[1].num]<<endl;
- for(int j=3;j<=n;j++) cout<<p[a[j].num]<<endl;
- wait;
- cls;
- pp();
- cout<<"第九步~祈福仪式的最后一个环节:"<<s2<<endl<<endl;
- for(int j=2;j<=n;j++) cout<<p[a[j].num]<<endl;
- wait;
- cls;
- pp();
- cout<<"第九步~祈福仪式的最后一个环节:"<<s2<<endl;
- for(int j=1;j<=n;j++) b[j]=a[j];
- for(int j=2;j<=n;j++) a[j-1]=b[j];
- n--;
- print();
- wait1;
- }
- }
- stop;
- cls;
- }
- void End(){
- pp();
- cout<<"现在拿出我们藏起来的神秘半张牌\n";
- print();
- wait;
- cls;
- cout<<"藏牌:\n现在拿出我们藏起来的神秘半张牌\n";
- print();
- wait;
- cls;
- cout<<"现在拿出我们藏起来的神秘半张牌\n";
- cout<<p[a[1].num]<<" "<<p[hide];
- wait;
- cls;
- if(p[a[1].num]==p[hide]){
- cout<<"现在拿出我们藏起来的神秘半张牌\n";
- cout<<p[a[1].num]<<" "<<p[hide];
- wait;
- cls;
- cout<<"现在拿出我们藏起来的神秘半张牌\n";
- cout<<p[a[1].num]<<" "<<p[hide];
- wait;
- cls;
- cout<<"现在拿出我们藏起来的神秘半张牌\n";
- cout<<p[a[1].num]<<p[hide];
- wait;
- cls;
- cout<<"现在拿出我们藏起来的神秘半张牌\n";
- cout<<p[hide];
- wait;
- cls;
- cout<<"恭喜你破镜重圆,完成祈福仪式~\n接下来你将顺风顺水,开心快乐一整年!\n";
- cout<<p[hide];
- wait;
- }
- else{
- cout<<"Woops!穿帮了!请重新开始。\n";
- cout<<p[a[1].num]<<" "<<p[hide];
- wait;
- }
- }
- int main(){
- cout<<"祈福时间到~请发牌\n";
- wait;
- FirstStep();
- SecondStep();
- ThirdStep();
- FourthStep();
- FifthStep();
- SixthStep();
- SeventhStep();
- EighthStep();
- NinthStep();
- End();
- return 0;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。