小游戏
2026-04-29 20:26:13
发布于:湖北
//建议用Dev-C++
#include<bits/stdc++.h>
using namespace std;
int main() {
int a,d=0,e=0,f,g,u;
while(true){
cout<<"(0开始游戏)(999退出)";
cout<<endl;
cin>>a;
if(a==0){
int h=3;
while(h>0){
int b=10;
int c=0;
srand((unsigned)time(NULL));
c=rand()%100+1;
while(b>=0){
cout<<"第"<<4-h<<"局"<<endl;
cout<<"猜数字(1~100)"<<endl;
cout<<"(剩余"<<b<<"次)"<<endl;
cout<<"(分数"<<d<<"分)(满分300分)"<<endl;
cin>>e;
cout<<endl;
if(e==c){
cout<<"猜对了"<<endl;
cout<<"分数+"<<b*10<<endl;
d+=b*10;
cout<<"(分数)"<<d<<"(满分100分)";
cout<<"是否继续(0继续)(999退出)"<<endl;
cin>>u;
if(u==999){
cout<<"游戏结束"<<endl<<"得分:"<<d;
return 0;}
}else{
cout<<"猜错了"<<endl;
if(e>c){
cout<<e<<"大了"<<endl;
}else if(e<c){
cout<<e<<"小了"<<endl;
}
}
b--;
}
h--;}
cout<<"是否继续(0继续)(999退出)";
}else{
cout<<"游戏结束"<<endl<<"得分:"<<d;
break;
}
}
return 0;}****加粗文本****
**
制作不易
点个赞再走
全部评论 1
- 置顶
作者挺辛苦(已点赞)
2026-04-29 来自 天津
2不小心把你的删了请重发一下sorry
2026-05-02 来自 湖北
1#include <bits/stdc++.h> #define clear() printf("\033c") #include <windows.h> using namespace std; char c[4][4]; int cnt; void on() { for(int i = 1; i <= 3; i++) { for(int j = 1; j <= 3; j++) { cout << c[i][j] << " "; } cout << endl; } } bool check() { for(int i = 1; i <= 3; i++) { if(c[i][1] == 'o' && c[i][2] == 'o' && c[i][3] == 'o') return true; } for(int i = 1; i <= 3; i++) { if(c[i][1] == 'x' && c[i][2] == 'x' && c[i][3] == 'x') return true; } for(int i = 1; i <= 3; i++) { if(c[1][i] == 'o' && c[2][i] == 'o' && c[3][i] == 'o') return true; } for(int i = 1; i <= 3; i++) { if(c[1][i] == 'x' && c[2][i] == 'x' && c[3][i] == 'x') return true; } if(c[1][1] == 'o' && c[2][2] == 'o' && c[3][3] == 'o') return true; if(c[1][1] == 'x' && c[2][2] == 'x' && c[3][3] == 'x') return true; if(c[1][3] == 'o' && c[2][2] == 'o' && c[3][1] == 'o') return true; if(c[1][3] == 'x' && c[2][2] == 'x' && c[3][1] == 'x') return true; return false; } bool ss() { for(int i = 1; i <= 3; i++) { for(int j = 1; j <= 3; j++) { if(c[i][j] == '-') return false; } } return true; } int main() { cnt = 1; for(int i = 1; i <= 3; i++) { for(int j = 1; j <= 3; j++) { c[i][j] = '-'; } } while(true) { int x, y; clear(); if(cnt % 2 == 1) { on(); cout << "1号玩家选择" << endl << "行:"; cin >> x; cout << "列:"; cin >> y; if(c[x][y] == '-') { c[x][y] = 'o'; cnt++; } else { clear(); cout << "选择无效" << endl; Sleep(2000); // 暂停 2000 毫秒(即 2 秒) continue; }2026-05-02 来自 天津
1clear(); if(check()) { clear(); on(); cout << endl; cout << "1号玩家胜利" << endl; return 0; } } else { on(); cout << "2号玩家选择" << endl << "行:"; cin >> x; ```后半个2026-05-02 来自 天津
1























有帮助,赞一个