- 长方形面积计算
立新4.11讨论群
- 2025-6-26 12:18:02 @
#include <iostream>
using namespace std;
int main() {
cout << "Welcome!" << endl;
return 0;
}
19 条评论
-
张柏然 @ 2025-9-16 16:05:32
否则我锁
-
2025-9-16 16:05:04@
请不要乱发
-
2025-9-15 17:26:28@
#include<bits/stdc++.h> using namespace std; int a[100001]; int main(){ long long N,m=0; cin>>N; for(int i=1;i<=N;++i){ cin>>a[i]; } for(int i=1;i<=N;++i){ for(int j=1;j<=N-1;++j){ if(a[i]<a[m]){ swap(a[i],a[m]); } ++m; } m=0; } return 0; }
-
2025-9-14 16:12:44@
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>迷宫游戏</title> <script src="https://cdn.tailwindcss.com"></script> <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet"> <!-- Tailwind 配置 --> <script> tailwind.config = { theme: { extend: { colors: { primary: '#3B82F6', secondary: '#10B981', accent: '#F59E0B', wall: '#1F2937', path: '#F9FAFB', player: '#EC4899', exit: '#8B5CF6' }, fontFamily: { game: ['"Press Start 2P"', 'cursive', 'sans-serif'] } } } } </script> <style type="text/tailwindcss"> @layer utilities { .maze-cell { @apply w-8 h-8 sm:w-10 sm:h-10 md:w-12 md:h-12 flex items-center justify-center transition-all duration-200; } .wall-cell { @apply bg-wall; } .path-cell { @apply bg-path; } .player-cell { @apply text-player; } .exit-cell { @apply text-exit; } .game-shadow { @apply shadow-lg shadow-gray-500/50; } .btn-hover { @apply hover:scale-105 active:scale-95 transition-all duration-150; } } </style> <!-- 导入游戏字体 --> <link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet"> </head> <body class="bg-gray-100 min-h-screen flex flex-col items-center justify-center p-4 font-sans"> <div class="max-w-4xl w-full mx-auto flex flex-col items-center"> <!-- 游戏标题 --> <h1 class="text-[clamp(1.5rem,5vw,2.5rem)] font-game text-primary mb-6 text-center tracking-wider"> 迷宫探险 </h1> <!-- 游戏信息面板 --> <div class="w-full bg-white rounded-lg p-4 mb-6 game-shadow flex flex-wrap justify-between items-center gap-4"> <div class="flex items-center gap-2"> <i class="fa fa-clock-o text-accent text-xl"></i> <span class="font-bold">时间: <span id="timer" class="text-primary">0s</span></span> </div> <div class="flex items-center gap-2"> <i class="fa fa-signal text-accent text-xl"></i> <span class="font-bold">步数: <span id="steps" class="text-primary">0</span></span> </div> <div class="flex gap-3"> <button id="newGameBtn" class="bg-primary hover:bg-primary/90 text-white px-4 py-2 rounded-lg btn-hover flex items-center gap-2"> <i class="fa fa-refresh"></i> 新游戏 </button> <button id="controlsBtn" class="bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg btn-hover flex items-center gap-2"> <i class="fa fa-gamepad"></i> 控制 </button> </div> </div> <!-- 迷宫容器 --> <div id="mazeContainer" class="bg-gray-200 p-4 rounded-lg game-shadow overflow-auto max-h-[70vh]"> <div id="maze" class="grid gap-0 mx-auto"></div> </div> <!-- 游戏说明 --> <div class="mt-6 bg-white p-4 rounded-lg game-shadow text-center max-w-md"> <p class="text-gray-700">使用 <strong>方向键</strong> 或 <strong>WASD</strong> 移动玩家,找到出口!</p> </div> <!-- 控制提示模态框 --> <div id="controlsModal" class="fixed inset-0 bg-black/50 flex items-center justify-center z-50 hidden"> <div class="bg-white rounded-lg p-6 max-w-md w-full mx-4"> <h2 class="text-xl font-bold text-primary mb-4 text-center">游戏控制</h2> <div class="grid grid-cols-2 gap-4"> <div class="flex flex-col items-center"> <div class="bg-gray-100 p-3 rounded mb-2"> <span class="font-bold">W 或 ↑</span> </div> <span>向上移动</span> </div> <div class="flex flex-col items-center"> <div class="bg-gray-100 p-3 rounded mb-2"> <span class="font-bold">S 或 ↓</span> </div> <span>向下移动</span> </div> <div class="flex flex-col items-center"> <div class="bg-gray-100 p-3 rounded mb-2"> <span class="font-bold">A 或 ←</span> </div> <span>向左移动</span> </div> <div class="flex flex-col items-center"> <div class="bg-gray-100 p-3 rounded mb-2"> <span class="font-bold">D 或 →</span> </div> <span>向右移动</span> </div> </div> <button id="closeControlsBtn" class="mt-6 w-full bg-primary hover:bg-primary/90 text-white py-2 rounded-lg btn-hover"> 关闭 </button> </div> </div> <!-- 胜利模态框 --> <div id="winModal" class="fixed inset-0 bg-black/50 flex items-center justify-center z-50 hidden"> <div class="bg-white rounded-lg p-6 max-w-md w-full mx-4 text-center"> <div class="text-accent text-5xl mb-4"> <i class="fa fa-trophy"></i> </div> <h2 class="text-2xl font-bold text-primary mb-2">恭喜你!</h2> <p class="mb-2">你成功走出了迷宫!</p> <p class="mb-4">用时: <span id="winTime" class="font-bold">0s</span> | 步数: <span id="winSteps" class="font-bold">0</span></p> <button id="playAgainBtn" class="w-full bg-primary hover:bg-primary/90 text-white py-2 rounded-lg btn-hover"> 再玩一次 </button> </div> </div> </div> <script> // 游戏配置 const config = { // 根据屏幕尺寸调整迷宫大小 mazeSize: window.innerWidth < 640 ? 10 : window.innerWidth < 768 ? 15 : 20, player: '🧍', // 玩家角色 exit: '🚪' // 出口 }; // 游戏状态 const gameState = { maze: [], playerPosition: { x: 1, y: 1 }, exitPosition: { x: 0, y: 0 }, steps: 0, timer: 0, timerInterval: null, gameStarted: false }; // DOM 元素 const mazeElement = document.getElementById('maze'); const stepsElement = document.getElementById('steps'); const timerElement = document.getElementById('timer'); const newGameBtn = document.getElementById('newGameBtn'); const controlsBtn = document.getElementById('controlsBtn'); const closeControlsBtn = document.getElementById('closeControlsBtn'); const controlsModal = document.getElementById('controlsModal'); const winModal = document.getElementById('winModal'); const winTimeElement = document.getElementById('winTime'); const winStepsElement = document.getElementById('winSteps'); const playAgainBtn = document.getElementById('playAgainBtn'); // 初始化事件监听 function initEventListeners() { // 键盘控制 document.addEventListener('keydown', handleKeyPress); // 按钮控制 newGameBtn.addEventListener('click', startNewGame); controlsBtn.addEventListener('click', () => controlsModal.classList.remove('hidden')); closeControlsBtn.addEventListener('click', () => controlsModal.classList.add('hidden')); playAgainBtn.addEventListener('click', () => { winModal.classList.add('hidden'); startNewGame(); }); // 触摸控制 (移动设备) let touchStartX = 0; let touchStartY = 0; document.addEventListener('touchstart', (e) => { touchStartX = e.touches[0].clientX; touchStartY = e.touches[0].clientY; }, false); document.addEventListener('touchend', (e) => { if (!touchStartX || !touchStartY) return; const touchEndX = e.changedTouches[0].clientX; const touchEndY = e.changedTouches[0].clientY; const diffX = touchEndX - touchStartX; const diffY = touchEndY - touchStartY; // 确定滑动方向 (优先处理较大的差值) if (Math.abs(diffX) > Math.abs(diffY)) { // 水平滑动 if (diffX > 50) movePlayer(1, 0); // 右 else if (diffX < -50) movePlayer(-1, 0); // 左 } else { // 垂直滑动 if (diffY > 50) movePlayer(0, 1); // 下 else if (diffY < -50) movePlayer(0, -1); // 上 } touchStartX = 0; touchStartY = 0; }, false); } // 处理键盘按键 function handleKeyPress(e) { // 防止按键滚动页面 if ([37, 38, 39, 40, 65, 68, 83, 87].includes(e.keyCode)) { e.preventDefault(); } // 开始计时(第一次移动时) if (!gameState.gameStarted) { startTimer(); gameState.gameStarted = true; } // 根据按键移动玩家 switch(e.keyCode) { case 38: // 上箭头 case 87: // W movePlayer(0, -1); break; case 40: // 下箭头 case 83: // S movePlayer(0, 1); break; case 37: // 左箭头 case 65: // A movePlayer(-1, 0); break; case 39: // 右箭头 case 68: // D movePlayer(1, 0); break; } } // 生成迷宫 (使用递归回溯算法) function generateMaze(size) { // 确保迷宫尺寸为奇数 const mazeSize = size % 2 === 0 ? size + 1 : size; // 初始化迷宫 - 全部为墙 (1表示墙,0表示通路) const maze = Array(mazeSize).fill().map(() => Array(mazeSize).fill(1)); // 递归回溯函数 function carve(x, y) { // 标记当前单元格为通路 maze[y][x] = 0; // 随机排序方向 (上、右、下、左) const directions = [ [0, -2], [2, 0], [0, 2], [-2, 0] ].sort(() => Math.random() - 0.5); // 尝试每个方向 for (const [dx, dy] of directions) { const nx = x + dx; const ny = y + dy; // 检查是否在迷宫内 if (nx > 0 && nx < mazeSize && ny > 0 && ny < mazeSize && maze[ny][nx] === 1) { // 打通当前单元格与目标单元格之间的墙 maze[y + dy/2][x + dx/2] = 0; // 递归处理目标单元格 carve(nx, ny); } } } // 从左上角开始生成 (确保是奇数坐标) carve(1, 1); // 设置入口 (左上角) maze[1][0] = 0; // 设置出口 (右下角附近) const exitX = mazeSize - 2; const exitY = mazeSize - 2; maze[exitY][mazeSize - 1] = 0; // 记录出口位置 gameState.exitPosition = { x: mazeSize - 1, y: exitY }; return maze; } // 渲染迷宫 function renderMaze() { // 清空迷宫容器 mazeElement.innerHTML = ''; // 设置网格尺寸 mazeElement.style.gridTemplateColumns = `repeat(${gameState.maze[0].length}, auto)`; // 遍历迷宫并创建单元格 for (let y = 0; y < gameState.maze.length; y++) { for (let x = 0; x < gameState.maze[y].length; x++) { const cell = document.createElement('div'); cell.classList.add('maze-cell'); // 标记单元格类型 (墙或通路) if (gameState.maze[y][x] === 1) { cell.classList.add('wall-cell'); } else { cell.classList.add('path-cell'); // 放置玩家 if (x === gameState.playerPosition.x && y === gameState.playerPosition.y) { cell.classList.add('player-cell'); cell.innerHTML = config.player; } // 放置出口 else if (x === gameState.exitPosition.x && y === gameState.exitPosition.y) { cell.classList.add('exit-cell'); cell.innerHTML = config.exit; } } mazeElement.appendChild(cell); } } } // 移动玩家 function movePlayer(dx, dy) { const newX = gameState.playerPosition.x + dx; const newY = gameState.playerPosition.y + dy; // 检查新位置是否在迷宫内且不是墙 if ( newX >= 0 && newX < gameState.maze[0].length && newY >= 0 && newY < gameState.maze.length && gameState.maze[newY][newX] === 0 ) { // 更新玩家位置 gameState.playerPosition.x = newX; gameState.playerPosition.y = newY; // 增加步数 gameState.steps++; stepsElement.textContent = gameState.steps; // 重新渲染迷宫 renderMaze(); // 检查是否到达出口 checkWin(); } } // 检查是否获胜 function checkWin() { if ( gameState.playerPosition.x === gameState.exitPosition.x && gameState.playerPosition.y === gameState.exitPosition.y ) { // 停止计时器 stopTimer(); // 显示胜利模态框 winTimeElement.textContent = `${gameState.timer}s`; winStepsElement.textContent = gameState.steps; winModal.classList.remove('hidden'); } } // 开始计时器 function startTimer() { gameState.timer = 0; gameState.timerInterval = setInterval(() => { gameState.timer++; timerElement.textContent = `${gameState.timer}s`; }, 1000); } // 停止计时器 function stopTimer() { clearInterval(gameState.timerInterval); } // 开始新游戏 function startNewGame() { // 重置游戏状态 stopTimer(); gameState.steps = 0; gameState.gameStarted = false; stepsElement.textContent = '0'; timerElement.textContent = '0s'; // 生成新迷宫 gameState.maze = generateMaze(config.mazeSize); // 重置玩家位置到入口 gameState.playerPosition = { x: 0, y: 1 }; // 渲染迷宫 renderMaze(); } // 初始化游戏 function initGame() { initEventListeners(); startNewGame(); } // 启动游戏 window.addEventListener('DOMContentLoaded', initGame); </script> </body> </html>
.html
-
2025-9-12 21:20:02@
太空站探险如何获得胜利:
要在《太空站探险》游戏中获胜,需按以下步骤依次完成关键任务,同时注意管理氧气和健康值: 一、基础生存与初始物品收集 医疗舱起步 初始醒来后,先选择 “检查医疗舱” 获取 急救包(后续可恢复健康值)。 再选择 “前往走廊” 进入下一场景。 状态管理 随时通过各房间菜单中的 “查看状态和物品” 监控氧气(每行动约消耗5%)和健康值,避免归零导致游戏结束。 二、核心道具与关键区域探索 1. 储藏室:获取门禁卡与工具包 从走廊进入 储藏室,优先 “搜索箱子”: 首次搜索获得 门禁卡(解锁控制台和逃生舱门)。 再次搜索获得 工具包(用于修复通讯系统和提取燃料)。 可选择 “检查货架” 随机获取氧气补给(但有小概率触发货架倒塌扣血,建议健康值低时谨慎操作)。 2. 控制室:修复通讯系统 从走廊进入 控制室,使用门禁卡操作控制台: 选择 “尝试修复通讯系统”,需消耗 工具包,修复后发出救援信号(胜利必要条件)。 若未修复,启动逃生舱后会因无救援信号失败。 3. 引擎室:提取燃料 从走廊进入 引擎室,选择 “检查引擎”: 使用 工具包 提取燃料,获得 燃料罐(启动逃生舱必要道具)。 可搜索角落获取 氧气面罩(减缓氧气消耗,提高生存容错率)。 三、最终胜利:启动逃生舱 进入逃生舱 在引擎室选择 “尝试进入逃生舱”,使用门禁卡解锁舱门。 启动逃生舱 确保已满足两个条件: 拥有燃料(从引擎提取)。 通讯系统已修复(控制室操作)。 选择 “启动逃生舱”,成功发出救援信号,达成胜利结局。 关键提示 氧气优先:若氧气过低,可返回储藏室搜索箱子补充(概率恢复10%氧气),或检查货架获取备用氧气瓶(恢复20%)。 健康值管理:急救包可在任意房间通过“查看状态”使用(需手动选择,代码中未直接实现,需注意原文代码是否支持主动使用,若未支持则需避免受伤)。 流程顺序:建议路线为 医疗舱→走廊→储藏室(拿门禁卡+工具包)→控制室(修通讯)→引擎室(取燃料)→逃生舱。 按以上步骤操作,即可在氧气耗尽前完成所有目标,成功逃离太空站并获得救援!
-
2025-9-12 13:30:03@
#include <iostream> #include <string> #include <vector> #include <cstdlib> #include <ctime> #include <algorithm> using namespace std; // 游戏状态 struct GameState { int oxygen; // 氧气水平 int health; // 健康值 vector<string> items; // 物品列表 bool hasKeycard; // 是否有门禁卡 bool repairedComms; // 是否修复了通讯系统 bool hasFuel; // 是否有燃料 GameState() : oxygen(100), health(100), hasKeycard(false), repairedComms(false), hasFuel(false) {} // 检查是否拥有物品 bool hasItem(const string& item) { return find(items.begin(), items.end(), item) != items.end(); } // 添加物品 void addItem(const string& item) { if (!hasItem(item)) { items.push_back(item); cout << "获得了: " << item << endl; } } // 显示状态 void showStatus() { cout << "\n状态: 氧气 " << oxygen << "% | 健康 " << health << "%" << endl; cout << "物品: "; if (items.empty()) { cout << "无"; } else { for (size_t i = 0; i < items.size(); ++i) { if (i > 0) cout << ", "; cout << items[i]; } } cout << endl; } }; // 函数声明 void printTitle(const string& msg = ""); void gameOver(const string& reason); void victory(); int getChoice(int min, int max); void startRoom(GameState& state); void corridor(GameState& state); void controlRoom(GameState& state); void storageRoom(GameState& state); void engineRoom(GameState& state); void escapePod(GameState& state); // 打印标题 void printTitle(const string& msg) { system("cls"); // Windows清屏,Linux/Mac使用"clear" cout << "========================" << endl; cout << " 太空站探险" << endl; cout << "========================" << endl << endl; if (!msg.empty()) { cout << msg << endl << endl; } } // 游戏结束 void gameOver(const string& reason) { printTitle(); cout << "任务失败!" << endl; cout << reason << endl << endl; cout << "感谢游玩!" << endl; exit(0); } // 游戏胜利 void victory() { printTitle(); cout << "恭喜你!" << endl; cout << "你成功启动了逃生舱,离开了受损的太空站。" << endl; cout << "救援信号已发出,很快就会有飞船来接应你。" << endl << endl; cout << "任务成功完成!" << endl; exit(0); } // 获取玩家选择 int getChoice(int min, int max) { int choice; while (true) { cout << "请选择 (" << min << "-" << max << "): "; cin >> choice; if (cin.fail()) { cin.clear(); cin.ignore(1000, '\n'); cout << "无效输入,请输入数字。" << endl; } else if (choice >= min && choice <= max) { return choice; } else { cout << "请输入" << min << "到" << max << "之间的数字。" << endl; } } } // 起始房间 void startRoom(GameState& state) { // 氧气逐渐减少 state.oxygen -= 5; if (state.oxygen <= 0) { gameOver("氧气耗尽,任务失败。"); } printTitle("你在一个小型舱室中醒来,周围一片狼藉。"); cout << "这里似乎是太空站的医疗舱,警报声在远处回响。" << endl; cout << "舱室的门是打开的,外面是一条长长的走廊。" << endl << endl; cout << "1. 检查医疗舱" << endl; cout << "2. 前往走廊" << endl; cout << "3. 查看状态和物品" << endl; int choice = getChoice(1, 3); switch (choice) { case 1: printTitle("你检查了医疗舱。"); cout << "医疗柜里还有一些急救用品。" << endl; if (!state.hasItem("急救包")) { state.addItem("急救包"); cout << "急救包可以恢复健康值。" << endl; } else { cout << "医疗舱里没有其他有用的东西了。" << endl; } cout << endl << "按回车键继续..."; cin.ignore(); cin.get(); startRoom(state); break; case 2: corridor(state); break; case 3: state.showStatus(); cout << endl << "按回车键继续..."; cin.ignore(); cin.get(); startRoom(state); break; } } // 走廊 void corridor(GameState& state) { state.oxygen -= 5; if (state.oxygen <= 0) { gameOver("氧气耗尽,任务失败。"); } printTitle("你在一条昏暗的走廊里,应急灯闪烁着红光。"); cout << "走廊两侧有几个舱门,分别通向不同的区域。" << endl; cout << "远处传来奇怪的金属摩擦声。" << endl << endl; cout << "1. 前往控制室" << endl; cout << "2. 前往储藏室" << endl; cout << "3. 前往引擎室" << endl; cout << "4. 返回医疗舱" << endl; cout << "5. 查看状态和物品" << endl; int choice = getChoice(1, 5); switch (choice) { case 1: controlRoom(state); break; case 2: storageRoom(state); break; case 3: engineRoom(state); break; case 4: startRoom(state); break; case 5: state.showStatus(); cout << endl << "按回车键继续..."; cin.ignore(); cin.get(); corridor(state); break; } } // 控制室 void controlRoom(GameState& state) { state.oxygen -= 5; if (state.oxygen <= 0) { gameOver("氧气耗尽,任务失败。"); } printTitle("你进入了控制室,这里的屏幕大多已经失灵。"); cout << "中央控制台似乎还能勉强工作,但需要权限才能操作。" << endl << endl; if (state.repairedComms) { cout << "通讯系统已经修复,救援信号已发出。" << endl << endl; } cout << "1. 检查控制台" << endl; cout << "2. 搜索控制室" << endl; cout << "3. 返回走廊" << endl; cout << "4. 查看状态和物品" << endl; int choice = getChoice(1, 4); switch (choice) { case 1: printTitle("你尝试操作控制台。"); if (state.hasKeycard) { cout << "你使用门禁卡获得了控制台权限。" << endl; if (!state.repairedComms) { cout << "1. 尝试修复通讯系统" << endl; cout << "2. 查看太空站状态" << endl; cout << "3. 退出控制台" << endl; int consoleChoice = getChoice(1, 3); if (consoleChoice == 1) { if (state.hasItem("工具包")) { cout << endl << "你使用工具包成功修复了通讯系统!" << endl; cout << "救援信号已自动发出!" << endl; state.repairedComms = true; } else { cout << endl << "你需要工具包才能修复通讯系统。" << endl; } } else if (consoleChoice == 2) { cout << endl << "太空站状态:多处受损,氧气系统泄漏,引擎离线。" << endl; cout << "逃生舱状态:需要燃料才能启动。" << endl; } } else { cout << "控制台显示:救援信号已发出,等待救援中。" << endl; cout << "逃生舱位于引擎室旁边,需要燃料才能启动。" << endl; } } else { cout << "控制台需要门禁卡才能操作。" << endl; } cout << endl << "按回车键继续..."; cin.ignore(); cin.get(); controlRoom(state); break; case 2: printTitle("你搜索了控制室。"); if (!state.hasItem("日志本")) { state.addItem("日志本"); cout << "日志本记录了太空站事故的原因:陨石撞击导致系统故障。" << endl; cout << "还提到门禁卡可能在储藏室。" << endl; } else { cout << "控制室里没有其他有用的东西了。" << endl; } cout << endl << "按回车键继续..."; cin.ignore(); cin.get(); controlRoom(state); break; case 3: corridor(state); break; case 4: state.showStatus(); cout << endl << "按回车键继续..."; cin.ignore(); cin.get(); controlRoom(state); break; } } // 储藏室 void storageRoom(GameState& state) { state.oxygen -= 5; if (state.oxygen <= 0) { gameOver("氧气耗尽,任务失败。"); } printTitle("你进入了储藏室,里面堆满了各种物资。"); cout << "几个箱子倒在地上,里面的东西散落一地。" << endl << endl; cout << "1. 搜索箱子" << endl; cout << "2. 检查货架" << endl; cout << "3. 返回走廊" << endl; cout << "4. 查看状态和物品" << endl; int choice = getChoice(1, 4); switch (choice) { case 1: printTitle("你开始搜索箱子。"); if (!state.hasKeycard) { cout << "在一个标有'重要物品'的箱子里,你找到了一张门禁卡!" << endl; state.hasKeycard = true; state.addItem("门禁卡"); } else if (!state.hasItem("工具包")) { cout << "你在一个箱子里找到了一个工具包。" << endl; state.addItem("工具包"); cout << "里面有各种维修工具,可能会有用。" << endl; } else { cout << "箱子里只有一些食品和水,你补充了能量。" << endl; state.oxygen += 10; if (state.oxygen > 100) state.oxygen = 100; cout << "氧气水平有所恢复。" << endl; } cout << endl << "按回车键继续..."; cin.ignore(); cin.get(); storageRoom(state); break; case 2: printTitle("你检查了货架。"); if (rand() % 2 == 0) { cout << "你找到了一个备用氧气瓶,更换后氧气水平提高了。" << endl; state.oxygen += 20; if (state.oxygen > 100) state.oxygen = 100; } else { cout << "货架上大多是损坏的设备,没有什么有用的东西。" << endl; // 随机事件:货架倒塌 if (rand() % 3 == 0) { cout << "突然,一个货架倒塌了,你被砸中了!" << endl; state.health -= 30; if (state.health <= 0) { gameOver("你受了重伤,无法继续任务。"); } } } cout << endl << "按回车键继续..."; cin.ignore(); cin.get(); storageRoom(state); break; case 3: corridor(state); break; case 4: state.showStatus(); cout << endl << "按回车键继续..."; cin.ignore(); cin.get(); storageRoom(state); break; } } // 引擎室 void engineRoom(GameState& state) { state.oxygen -= 5; if (state.oxygen <= 0) { gameOver("氧气耗尽,任务失败。"); } printTitle("你进入了引擎室,这里噪音很大,部分管道在漏气。"); cout << "主引擎看起来已经损坏,但旁边有一个通往逃生舱的门。" << endl << endl; cout << "1. 检查引擎" << endl; cout << "2. 尝试进入逃生舱" << endl; cout << "3. 搜索引擎室" << endl; cout << "4. 返回走廊" << endl; cout << "5. 查看状态和物品" << endl; int choice = getChoice(1, 5); switch (choice) { case 1: printTitle("你检查了主引擎。"); cout << "引擎严重损坏,无法修复。" << endl; if (state.hasItem("工具包")) { cout << "但你发现可以从引擎中提取一些剩余燃料。" << endl; cout << "1. 提取燃料" << endl; cout << "2. 放弃" << endl; int fuelChoice = getChoice(1, 2); if (fuelChoice == 1) { cout << endl << "你成功提取了一些燃料!" << endl; state.hasFuel = true; state.addItem("燃料罐"); } } else { cout << "你需要工具才能从引擎中提取燃料。" << endl; } cout << endl << "按回车键继续..."; cin.ignore(); cin.get(); engineRoom(state); break; case 2: if (state.hasKeycard) { escapePod(state); } else { printTitle("逃生舱的门是锁着的,需要门禁卡才能打开。"); cout << "1. 返回引擎室" << endl; getChoice(1, 1); engineRoom(state); } break; case 3: printTitle("你搜索了引擎室。"); cout << "在一个角落,你发现了一个氧气面罩。" << endl; if (!state.hasItem("氧气面罩")) { state.addItem("氧气面罩"); cout << "氧气面罩可以减缓氧气消耗。" << endl; } else { cout << "这里没有其他有用的东西了。" << endl; } cout << endl << "按回车键继续..."; cin.ignore(); cin.get(); engineRoom(state); break; case 4: corridor(state); break; case 5: state.showStatus(); cout << endl << "按回车键继续..."; cin.ignore(); cin.get(); engineRoom(state); break; } } // 逃生舱 void escapePod(GameState& state) { state.oxygen -= 5; if (state.oxygen <= 0) { gameOver("氧气耗尽,任务失败。"); } printTitle("你进入了逃生舱,里面空间很小但设备完好。"); cout << "逃生舱的控制面板亮着,等待启动。" << endl << endl; if (state.hasFuel) { cout << "你有燃料,可以启动逃生舱。" << endl << endl; cout << "1. 启动逃生舱" << endl; cout << "2. 检查逃生舱设备" << endl; cout << "3. 返回引擎室" << endl; int choice = getChoice(1, 3); if (choice == 1) { if (state.repairedComms) { victory(); } else { printTitle("你启动了逃生舱,但通讯系统未修复。"); cout << "逃生舱成功离开了太空站,但没有发出救援信号。" << endl; cout << "你的命运未知..." << endl << endl; gameOver("虽然逃离了太空站,但可能永远漂流在太空中。"); } } else if (choice == 2) { cout << endl << "逃生舱设备正常,只需燃料即可启动。" << endl; cout << "建议先修复通讯系统再启动,以便发出救援信号。" << endl; cout << endl << "按回车键继续..."; cin.ignore(); cin.get(); escapePod(state); } else { engineRoom(state); } } else { cout << "逃生舱没有燃料,无法启动。" << endl; cout << "你需要找到燃料才能启动逃生舱。" << endl << endl; cout << "1. 返回引擎室" << endl; getChoice(1, 1); engineRoom(state); } } // 主函数 int main() { srand(time(0)); GameState state; printTitle("欢迎来到太空站探险!"); cout << "你是一名宇航员,在太空站遭遇事故后醒来。" << endl; cout << "你的任务是修复通讯系统,找到燃料," << endl; cout << "启动逃生舱并发出救援信号。" << endl; cout << "注意保持氧气和健康值,它们会不断消耗。" << endl << endl; cout << "1. 开始游戏" << endl; cout << "2. 退出游戏" << endl; if (getChoice(1, 2) == 1) { startRoom(state); } else { cout << "再见!" << endl; } return 0; }
-
2025-9-12 13:24:39@
#include <iostream> #include <string> #include <cstdlib> #include <ctime> using namespace std; // 简单的游戏状态 bool hasKey = false; bool hasLight = false; bool gameOver = false; // 显示标题 void title(string msg) { system("cls"); // Windows清屏,Linux/Mac用"clear" cout << "==== 森林冒险 ====" << endl << endl; if (!msg.empty()) cout << msg << endl << endl; } // 游戏结束 void endGame(string reason) { title(""); cout << "游戏结束!" << endl << reason << endl; cout << "谢谢游玩!" << endl; exit(0); } // 胜利 void victory() { endGame("你找到了宝藏,并成功逃出了森林!恭喜你!"); } // 获取选择 int choose(int min, int max) { int c; while (true) { cout << "请选择 (" << min << "-" << max << "): "; cin >> c; if (c >= min && c <= max) return c; cout << "无效选择,请重试。" << endl; } } int main() { srand(time(0)); int location = 1; // 1:入口 2:小屋 3:路口 4:洞穴 title("你在森林中醒来,需要找到宝藏并离开。"); cout << "1. 开始探索" << endl << "2. 退出" << endl; if (choose(1, 2) == 2) endGame("你决定放弃冒险。"); while (!gameOver) { switch(location) { case 1: // 森林入口 title("你在森林入口,面前有两条路。"); cout << "1. 去破旧木屋" << endl << "2. 进入森林深处" << endl; location = choose(1, 2) == 1 ? 2 : 3; break; case 2: // 旧木屋 title("你来到一座旧木屋前。"); cout << "1. 进入木屋" << endl << "2. 检查屋后" << endl << "3. 返回入口" << endl; switch(choose(1, 3)) { case 1: title("木屋里很暗,桌上有一根蜡烛。"); hasLight = true; cout << "你获得了蜡烛!" << endl << "按回车继续..."; cin.ignore(); cin.get(); break; case 2: title("屋后有个箱子。"); if (!hasKey) { hasKey = true; cout << "你找到了一把钥匙!" << endl; } else cout << "这里没有其他东西了。" << endl; cout << "按回车继续..."; cin.ignore(); cin.get(); break; case 3: location = 1; break; } break; case 3: // 十字路口 title("你来到十字路口。"); cout << "1. 去洞穴" << endl << "2. 沿小溪走" << endl << "3. 返回入口" << endl; switch(choose(1, 3)) { case 1: location = 4; break; case 2: title(rand()%2 ? "小溪边有野果,你恢复了体力。" : "小溪尽头是瀑布,你必须返回。"); cout << "按回车继续..."; cin.ignore(); cin.get(); break; case 3: location = 1; break; } break; case 4: // 洞穴 title("黑暗的洞穴入口。"); if (!hasLight) { cout << "太黑了,需要光源才能进入。" << endl; cout << "1. 返回路口" << endl; choose(1, 1); location = 3; } else { cout << "1. 进入洞穴深处" << endl << "2. 返回路口" << endl; if (choose(1, 2) == 1) { title("洞穴深处有个宝箱!"); if (hasKey) { cout << "你用钥匙打开了宝箱,发现了宝藏!" << endl; choose(1, 1); victory(); } else { cout << "宝箱是锁着的,你需要钥匙。" << endl; cout << "按回车继续..."; cin.ignore(); cin.get(); } } else location = 3; } break; } } return 0; }
-
2025-9-12 13:17:34@
#include <iostream> using namespace std; int main() { long long n; cin >> n; long long count = (n / 3) * 2; if (n % 3 == 2) { count += 1; } cout << count << endl; return 0; }
-
2025-9-10 13:26:19@
#include <iostream> #include <string> using namespace std; int main() { int choice; string name; cout << "欢迎来到文字冒险游戏!" << endl; cout << "请输入你的名字: "; cin >> name; cout << endl << "你好," << name << "!你的冒险即将开始..." << endl << endl; // 场景1 cout << "你在一个黑暗的森林中醒来。" << endl; cout << "你的面前有两条路:" << endl; cout << "1. 左边的路,看起来阴森但平坦" << endl; cout << "2. 右边的路,有微弱的光亮但崎岖" << endl; cout << "你选择哪条路?"; cin >> choice; if (choice == 1) { // 场景2A cout << endl << "你沿着左边的路走,周围越来越暗。" << endl; cout << "突然,你看到一只狼挡在路中间!" << endl; cout << "1. 尝试逃跑" << endl; cout << "2. 捡起一根木棍,准备战斗" << endl; cout << "你的选择?"; cin >> choice; if (choice == 1) { cout << endl << "狼迅速追上了你,你被狼攻击了..." << endl; cout << "冒险结束,你失败了!" << endl; } else { cout << endl << "你用木棍击退了狼,但也受了点伤。" << endl; cout << "继续前进,你找到了一个小木屋,在那里得到了帮助。" << endl; cout << "恭喜," << name << "!你成功完成了冒险!" << endl; } } else { // 场景2B cout << endl << "你沿着右边的路走,光亮越来越明显。" << endl; cout << "你来到一个湖边,湖中有一艘小船。" << endl; cout << "1. 乘船渡过湖去" << endl; cout << "2. 沿着湖边寻找其他路径" << endl; cout << "你的选择?"; cin >> choice; if (choice == 1) { cout << endl << "船到湖中心时开始漏水,你奋力游到了对岸。" << endl; cout << "虽然湿透了,但你成功到达了森林的另一边。" << endl; cout << "恭喜," << name << "!你成功完成了冒险!" << endl; } else { cout << endl << "你沿着湖边走,掉进了一个猎人设下的陷阱。" << endl; cout << "你无法挣脱,冒险结束了!" << endl; } } return 0; }
-
2025-9-10 13:17:14@
#include<bits/stdc++.h> #include<windows.h> #include<conio.h> #include<cstdio> #define random(a1,a2) rand()/(a2-a1+1)+a1 // 哈希函数:用于加密密钥 unsigned int simpleHash(int key) { unsigned int hash = 0; std::string keyStr = std::to_string(key); for (char c : keyStr) { hash = hash * 31 + c; } return hash; } using namespace std; struct user { char name[10000]; char ch; int marketvip; int talk; int power_of_earth; int blood,Gold,exp,LOVE,angry,true_fight,true_blooked; int cheat_used; // 开挂次数计数器 }; struct computer { int blood,Gold,exp,true_fight,true_blooked,angry; }; user a; computer b; FILE *fin,*fout; const unsigned int SECRET_KEY_HASH = 1952446877; const int MAX_CHEAT_USE = 3; // 最大使用次数 int item[]={0,160,1500,13500,66000,160,1440,13500,125000,160,1400,14000,125000,1100000,1100000,4800000,4800000}; int lv[1001]={0 , 0 , 10 , 25 , 100 , 200 , 400 , 500 , 1000 , 1600 , 2400 , 4000 , 6250 , 8750 , 10000 , 12500 , 15000 , 18000 , 22500 , 25000 , 30000 , 37500 , 50000 , 75000 , 125000}; int blood_[1001]={0 , 100 , 125 , 150 , 200 , 250 , 300 , 500 , 800 , 1250 , 1600 , 2000 , 2500 , 4000 , 6250 , 9750 , 12500 , 16000 , 18000 , 24000 , 32000 , 40000 , 48000 , 60000 , 80000 }; void start(); void game(); void out(string,float); short fight(string name,int blood,int fight,int blooked); bool boss(int blood,int fight,int blooked); int main() { srand(int(time(NULL))); a.Gold=0; a.LOVE=1; a.exp=0; a.marketvip=0; a.talk=0; a.power_of_earth=0; a.cheat_used=0; // 初始化开挂次数 for(int i=25;i<=600;i++) { lv[i]=(lv[i-1]*3-lv[i-2])-(lv[i-1]*3-lv[i-2])%10000; blood_[i]=(blood_[i-1]*3-blood_[i-2])-(blood_[i-1]*3-blood_[i-2])%10000; } for(int i=601;i<=1000;i++) blood_[i]=lv[i]=2000000000,blood_[i]-=400000000; cout<<"\t\t\t\t\t\t怪兽纪元\n"; cout<<"\n\n\n\n"; cout<<"\t\t\t\t\t\t1.开始新游戏\n"; cout<<"\t\t\t\t\t\t2.使用旧存档\n"; int say_in; cin>>say_in; if(say_in==1) { fout=fopen("Archive.Archive","wb"); fprintf(fout,"%s\n1\n0\n0\n0\n0\n0\n0\n0\n0\n",a.name); fin=fopen("Archive.Archive","rb"); fscanf(fin,"%s%d%d%d%d%d%d%d%d%d",&a.name,&a.LOVE,&a.exp,&a.Gold,&a.true_fight,&a.true_blooked,&a.marketvip,&a.talk,&a.power_of_earth,&a.cheat_used); fclose(fout); fclose(fin); start(); } else { fin=fopen("Archive.Archive","rb"); fscanf(fin,"%s%d%d%d%d%d%d%d%d%d",&a.name,&a.LOVE,&a.exp,&a.Gold,&a.true_fight,&a.true_blooked,&a.marketvip,&a.talk,&a.power_of_earth,&a.cheat_used); fclose(fin); game(); } } void start() { system("cls"); cout<<"\t\t\t\t\t\t怪兽纪元"; Sleep(1000); out("\n“XXX年,”\n",0.01); Sleep(500); out("“怪兽入侵S王国,”\n“战火四起,数千万人无家可归”",0.01); getchar(); out("\n......\n“整个王国陷入了绝望”",0.01); out("\n“而本国的公主也被怪兽之王附身,去往了一个小岛上...”",0.01); Sleep(1000); system("cls"); int x=GetSystemMetrics(SM_CXSCREEN); int y=GetSystemMetrics(SM_CYSCREEN); for(int i=25;i;i--) { SetCursorPos(rand()%x,rand()%y); Sleep(40); } Sleep(1000); out("你的耳旁响起了一个声音:\"你是与怪兽之王对战时被打伤的,你已经昏迷了十一年,你是唯一幸存的能拯救王国的人!它们去往了骷髅岛那个与世隔绝的地方,国王希望你能够去救公主,你是我们国家的希望!!!\"\n",0.01); getch(); Sleep(2000); system("cls"); out("你抬头看了看四周,这是个岛,海外围裹着一层强力台风,里面是危险的丛林,旁边旧损的牌子上写着Skull Island(骷髅岛)...\n",0.01); Sleep(1000); out("勇者,请输入你的名字\n",0.01); cin>>a.name; system("cls"); out("哦,",0.08); out(a.name,0.08); out(",真是个好名字,开始你的旅途吧!!!",0.08); Sleep(200); game(); } void out(string str,float time) { for(int i=0;i<str.size();i++) { Sleep(time*1000); cout<<str[i]; } } short fight(string name,int blood,int fight,int blooked) { int WayToFight,falseblood=blood,angry=0; while(true) { a.angry++,angry++; system("cls"); cout<<"你的血量:"<<a.blood<<"\t敌方血量:"<<blood<<"\n你的攻击力:"<<a.true_fight<<"\t敌方攻击力:"<<fight<<"\n你的防御力:"<<a.true_blooked<<"\t敌方防御力:"<<blooked<<"\n我方回合:\n1.普通攻击\t2.怒气攻击(怒气:"<<a.angry<<"/5"; if(a.angry<5) cout<<",暂时不够"; cout<<")\t3.逃跑\n"; cin>>WayToFight; if(WayToFight==1) if(random(1,5)==1) { out("你打出了暴击,对"+name+"造成了",0.06); if(a.true_fight>blooked) { cout<<(a.true_fight-blooked)*2; blood-=(a.true_fight-blooked)*2; } else cout<<0; out("点伤害",0.01); } else { out("你打掉了他",0.01); if(a.true_fight>blooked) { cout<<(a.true_fight-blooked); blood-=(a.true_fight-blooked); } else cout<<0; out("滴血",0.01); } if(WayToFight==2) if(a.angry>4) { a.angry-=5; out("你使用了怒气攻击,敌方扣了",0.01); if(a.true_fight>blooked) { cout<<(a.true_fight-blooked)*5; blood-=(a.true_fight-blooked)*5; } else cout<<0; out("滴血",0.01); } if(WayToFight==3) if(blood*1.0/falseblood<0.4 and random(1,3)<3) if(random(1,3)==1) { out(a.name,0.06); out(":I'm out of here.",0.06); return 2; } else if(random(1,2)==1) { out(a.name,0.01); out(":别拖我后腿。",0.01); return 2; } else { out(a.name,0.01); out(":我先走一步",0.01); return 2; } else { out(name,0.01); out(":想得美!",0.01); } if(blood<=0) return 1; Sleep(600); system("cls"); cout<<"你的血量:"<<a.blood<<"\t敌方血量:"<<blood<<"\n你的攻击力:"<<a.true_fight<<"\t敌方攻击力:"<<fight<<"\n你的防御力:"<<a.true_blooked<<"\t敌方防御力:"<<blooked<<"\n敌方回合:\n"; if(blood*1.0/falseblood<0.01) { if(rand()%100<40) { out(name+":我先走一步。",0.01); return 2; } } else if(angry>4) { angry-=5; out("敌方使用了怒气攻击,你扣了",0.01); if(fight>a.true_blooked) { cout<<(fight-a.true_blooked)*5; a.blood-=(fight-a.true_blooked)*5; } else cout<<0; out("滴血",0.01); } else { if(random(1,5)==1) { out("他打出了暴击,对你造成了",0.06); if(fight>a.true_blooked) { cout<<(fight-a.true_blooked)*2; a.blood-=(fight-a.true_blooked)*2; } else cout<<0; out("点伤害",0.01); } else { out("他打掉了你",0.01); if(fight>a.true_blooked) { cout<<(fight-a.true_blooked); a.blood-=(fight-a.true_blooked); } else cout<<0; out("滴血",0.01); } } if(a.blood<=0) return 0; } } bool boss(int blood,int fight,int blooked) { int WayToFight,falseblood=blood,angry=0; while(true) { a.angry++,angry++; system("cls"); cout<<"你的血量:"<<a.blood<<"\t怪兽之王血量:"<<blood<<"\n你的攻击力:"<<a.true_fight<<"\t怪兽之王攻击力:"<<fight<<"\n你的防御力:"<<a.true_blooked<<"\t怪兽之王防御力:"<<blooked<<"\n我方回合:\n1.普通攻击\t2.怒气攻击(怒气:"<<a.angry<<"/5"; if(a.angry<5) cout<<",暂时不够"; cout<<")"; cin>>WayToFight; if(WayToFight==1) if(random(1,5)==1) { out("你打出了暴击,对怪兽之王造成了",0.06); if(a.true_fight>blooked) { cout<<(a.true_fight-blooked)*2; blood-=(a.true_fight-blooked)*2; } else cout<<0; out("点伤害",0.01); } else { out("你打掉了他",0.01); if(a.true_fight>blooked) { cout<<(a.true_fight-blooked); blood-=(a.true_fight-blooked); } else cout<<0; out("滴血",0.01); } if(WayToFight==2) if(a.angry>4) { a.angry-=5; out("你使用了怒气攻击,敌方扣了",0.01); if(a.true_fight>blooked) { cout<<(a.true_fight-blooked)*5; blood-=(a.true_fight-blooked)*5; } else cout<<0; out("滴血",0.01); } if(blood<=0) return true; Sleep(600); system("cls"); cout<<"你的血量:"<<a.blood<<"\t怪兽之王血量:"<<blood<<"\n你的攻击力:"<<a.true_fight<<"\t怪兽之王攻击力:"<<fight<<"\n你的防御力:"<<a.true_blooked<<"\t怪兽之王防御力:"<<blooked<<"\n敌方回合:\n"; if(angry>4) { angry-=5; out("怪兽之王使用了怒气攻击,你扣了",0.01); if(fight>a.true_blooked) { cout<<(fight-a.true_blooked)*5; a.blood-=(fight-a.true_blooked)*5; } else cout<<0; out("滴血",0.01); } else { if(random(1,5)==1) { out("他打出了暴击,对你造成了",0.06); if(fight>a.true_blooked) { cout<<(fight-a.true_blooked)*2; a.blood-=(fight-a.true_blooked)*2; } else cout<<0; out("点伤害",0.01); } else { out("他打掉了你",0.01); if(fight>a.true_blooked) { cout<<(fight-a.true_blooked); a.blood-=(fight-a.true_blooked); } else cout<<0; out("滴血",0.01); } } if(a.blood<=0) return false; } } void game() { string his; int fightflag,TFeasy,choose; a.blood=blood_[a.LOVE]; Main: if(a.exp>=lv[a.LOVE+1]) { while(a.exp>=lv[a.LOVE+1]) a.exp-=lv[++a.LOVE]; out("\n你的等级增加了!",0.01); } a.angry=0; system("cls"); out("你想去做什么:\n",0.01); if(a.true_fight!=0 or a.true_blooked!=0) cout<<"1.探索\t2.商店\t3.存档\t4.查看\t5.开挂\t"; cout<<"6.对话\t"; if(a.power_of_earth) { cout<<"7.救公主\n"; } cout<<'\n'; cin>>a.ch; switch(a.ch) { case '5': // 开挂功能处理 if(a.true_fight!=0 or a.true_blooked!=0) { // 检查是否超过最大使用次数 if(a.cheat_used >= MAX_CHEAT_USE) { out("开挂次数已达上限,无法继续使用!\n",0.01); Sleep(1000); break; } out("输入秘钥:",0.01); cin>>choose; // 对输入的秘钥进行哈希计算后比对(使用新密钥20250903的哈希值) if(simpleHash(choose) == SECRET_KEY_HASH) { a.cheat_used++; // 次数加1 out("尊贵的VIP,请享受我们的服务.",0.01); out(".",0.333); out(".",0.333); Sleep(1000); system("cls"); cout<<"抽取资源中..."; a.blood=99999999; a.LOVE=20; a.Gold=99999999; a.true_fight=9999999; a.true_blooked=99999999; a.marketvip=1; a.talk=1; a.power_of_earth=1; Sleep(1000); system("cls"); cout<<"保存中..."; fout=fopen("Archive.Archive","wb"); fprintf(fout,"%s\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n", a.name,a.LOVE,a.exp,a.Gold,a.true_fight,a.true_blooked, a.marketvip,a.talk,a.power_of_earth,a.cheat_used); fclose(fout); out("\n开挂成功!剩余使用次数:" + to_string(MAX_CHEAT_USE - a.cheat_used) + "\n",0.01); Sleep(1000); } else { out("秘钥错误!\n",0.01); Sleep(1000); } } break; // 其他菜单选项的处理代码保持不变 case '1': if(a.true_fight!=0 or a.true_blooked!=0) goto steet; break; case '2': if(a.true_fight!=0 or a.true_blooked!=0) goto supermarket; break; case '3': if(a.true_fight!=0 or a.true_blooked!=0) { a.blood=blood_[a.LOVE]; fout=fopen("Archive.Archive","wb"); fprintf(fout,"%s\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n", a.name,a.LOVE,a.exp,a.Gold,a.true_fight,a.true_blooked, a.marketvip,a.talk,a.power_of_earth,a.cheat_used); fclose(fout); } break; case '4': if(a.true_fight!=0 or a.true_blooked!=0) goto info_; break; case '6': if(!a.talk) { out("'上一位'勇者:\"你是来救公主的吧?!我劝你小心一点,我之前来的十个勇者都死了,你现在没有攻击力、防御力,是连史莱姆都打不败的,我助你一臂之力,送你一瓶增幅药水,加油吧!\"\n",0.01); system("PAUSE"); system("cls"); out("你已获得6点攻击力!",0.01); a.talk=1; a.true_fight=6; Sleep(200); } else { if(rand()%10==0) { out("'上一位'勇者:\"对了,我打听到一个消息,只要你得到了大地结晶,你就能开启通往关押公主的地方的门,至于怎么获得?......我尚不知道。\"\n",0.01); system("PAUSE"); } else out("'上一位'勇者:\"加油!你是我们的希望!\"\n",0.01); } break; case '7': if(a.power_of_earth) { out("怪兽之王:\"又一个不自量力的人,敢来挑战我?!\"\n",0.01); out(a.name,0.01); out(":\"哼,我今天就得把你这个孽畜斩下,救出公主!!!\"\n",0.01); out("怪兽之王:\"噢,原来是老熟人啊。想救公主?!(冷笑了两声)那得看你的本事!!!\"\n",0.01); system("pause"); system("CLS"); out("你遭遇了怪兽之王。",0.01); if(boss(1000000,500000,500000)) { out("怪兽之王已被斩杀,勇者",0.01); out(a.name,0.01); out("救出了S国的公主。\n国王为了感谢勇者,便把公主许配给了",0.01); out(a.name,0.01); out("。\n从此,勇者和公主过上了幸福的生活\n(本游戏已完结,感谢游玩)",0.01); exit(0); } else { cout<<"\t\t\t\t\t\t失败"; system("start 怪兽纪元.exe"); } } break; } goto Main; // 探索和战斗相关代码(保持不变) steet: system("cls"); cout<<"1.寻宝\t2.挑战\n"; cin>>a.ch; switch(a.ch) { case '1': goto aaaaa; case '2': goto fight; default: goto Main; } aaaaa: system("cls"); Sleep(2000); b.Gold=rand()%50; a.Gold+=b.Gold; out("你捡到了",0.01); cout<<b.Gold; out("枚金币。",0.01); Sleep(10); goto Main; fight: system("cls"); if(a.LOVE<2) TFeasy=1; else if(a.LOVE<3) TFeasy=2; else if(a.LOVE<4) TFeasy=3; else if(a.LOVE<6) TFeasy=4; else if(a.LOVE<8) TFeasy=5; else if(a.LOVE<10) TFeasy=6; else if(a.LOVE<12) TFeasy=7; else if(a.LOVE<15) TFeasy=8; else if(a.LOVE<18) TFeasy=9; else if(a.LOVE<24) TFeasy=10; else TFeasy=11; switch(TFeasy>1?(TFeasy-rand()%4-1):(rand()%4+TFeasy-2)) { case 0: his ="史莱姆"; b.Gold=random(20,40); b.exp=10; b.blood=50; b.true_fight=5; b.true_blooked=1; break; case 1: his="食人花"; b.Gold=random(50,100); b.exp=25; b.blood=100; b.true_fight=60; b.true_blooked=20; break; case 2: his="红蝙蝠"; b.Gold=random(160,400); b.exp=50; b.blood=400; b.true_fight=40; b.true_blooked=60; break; case 3: his="灵骷髅"; b.Gold=random(800,1500); b.exp=250; b.blood=600; b.true_fight=250; b.true_blooked=80; case 4: his="巨人"; b.Gold=random(3000,5000); b.exp=800; b.blood=800; b.true_fight=800; b.true_blooked=80; break; case 5: his="金刚"; b.Gold=random(8000,10000); b.exp=2500; b.blood=1500; b.true_fight=1500; b.true_blooked=200; break; case 6: his="食人蚯蚓"; b.Gold=random(10000,40000); b.exp=12500; b.blood=15000; b.true_fight=2000; b.true_blooked=2000; break; case 7: his="朽灵法师"; b.Gold=random(60000,125000); b.exp=100000; b.blood=30000; b.true_fight=10000; b.true_blooked=6000; break; case 8: his="远古守卫"; b.Gold=random(150000,750000); b.exp=1250000; b.blood=80000; b.true_fight=10000; b.true_blooked=25000; break; case 9: his="巨龙"; b.Gold=random(1000000,3000000); b.exp=1250000; b.blood=100000; b.true_fight=50000; b.true_blooked=10000; break; case 10: his="大地之灵"; b.Gold=random(6000000,20000000); b.exp=3000000; b.blood=1000; b.true_fight=200000; b.true_blooked=400000; break; } out("你遭遇了"+his+",是(1)否(2)攻击?",0.01); cin>>a.ch; if(a.ch==49) { fightflag=fight(his,b.blood,b.true_fight,b.true_blooked); if(fightflag==1) { out("\n\t\t\t\t胜利\n",0.01); a.Gold+=b.Gold,a.exp+=b.exp; if(his=="大地之灵" and !a.power_of_earth) { out("恭喜你获得了大地结晶!\0",0.01); system("pause"); a.power_of_earth=1; } } else if(fightflag==0) { cout<<"\n\t\t\t\t失败\n"; Sleep(100); system("start 怪兽纪元.exe"); exit(0); } } goto Main; supermarket: system("cls"); out("神秘老人:你要买什么?\n",0.01); Sleep(200); cout<<"1.一瓶劣质经验药水(增长20经验)¥160\n2.一瓶低级经验药水(增长200经验)¥1500\n3.一瓶中级经验药水(增长2000经验)¥13500\n4.一瓶高级经验药水(增长10000经验)¥66000\n"; cout<<"5.一瓶劣质攻击药水(增长10攻击力)¥160\n6.一瓶低级攻击药水(增长100攻击力)¥1440\n7.一瓶中级攻击药水(增长1000攻击力)¥13500\n8.一瓶高级攻击药水(增长10000攻击力)¥125000\n"; cout<<"9.一瓶劣质防御药水(增长8防御力)¥160\n10.一瓶低级防御药水(增长80防御力)¥1400\n11.一瓶中级防御药水(增长875防御力)¥14000\n12.一瓶高级防御药水(增长7500防御力)¥125000\n"; if(a.marketvip) { cout<<"13.一瓶一阶极品攻击药水(增长100000攻击力)¥1100000\n14.一瓶一阶极品防御药水(增长90000防御力)¥1100000\n"; cout<<"15.一瓶最高阶极品攻击药水(增长500000攻击力)¥4800000\n16.一瓶最高阶极品防御药水(增长480000防御力)¥4800000\n"; } if(!a.marketvip) cout<<"999.高级通行证(可购买高级增幅药水)¥999999\n"; cout<<"0.返回\n"; cin>>choose; if(!choose) { out("神秘老人:慢走!",0.01); Sleep(200); goto Main; } if(choose==999) { if(a.marketvip) out("神秘老人:你不是已经办了么?\n",0.01); else { if(a.Gold<999999) out("神秘老人:钱不够,办不了!\n",0.01); else { a.Gold-=999999; a.marketvip=true; out("神秘老人:恭喜你能购买新物品了!!!\n",0.01); } } } else if(choose>16) out("神秘老人:没有这件商品!\n",0.01); else if(!a.marketvip and choose>12) out("神秘老人:没有这件商品!\n",0.01); else if(a.Gold<item[choose]) out("神秘老人:钱不够,买不了!\n",0.01); else { out("神秘老人:你已获得增幅!\n",0.06); Sleep(200); switch(choose) { case 1: a.exp+=20,a.Gold-=160; break; case 2: a.exp+=200,a.Gold-=1500; break; case 3: a.exp+=2000,a.Gold-=13500; break; case 4: a.exp+=10000,a.Gold-=66000; break; case 5: a.true_fight+=10,a.Gold-=160; break; case 6: a.true_fight+=100,a.Gold-=1440; break; case 7: a.true_fight+=1000,a.Gold-=13500; break; case 8: a.true_fight+=10000,a.Gold-=125000; break; case 9: a.true_blooked+=8,a.Gold-=160; break; case 10: a.true_blooked+=80,a.Gold-=1400; break; case 11: a.true_blooked+=875,a.Gold-=14000; break; case 12: a.true_blooked+=7500,a.Gold-=125000; break; case 13: if(a.marketvip) a.true_fight+=100000,a.Gold-=1100000; break; case 14: if(a.marketvip) a.true_blooked+=90000,a.Gold-=1100000; break; case 15: if(a.marketvip) a.true_fight+=500000,a.Gold-=4800000; break; case 16: if(a.marketvip) a.true_blooked+=480000,a.Gold-=4800000; break; } } goto supermarket; info_: system("cls"); Sleep(100); cout<<"\n\t\t\t\t\t名字:"<<a.name<<"\n\n\t\t\t\t\t目前血量:"<<a.blood<<"/"<<blood_[a.LOVE]<<"\n\t\t\t\t\t等级:"<<a.LOVE<<"\n\t\t\t\t\t还差"; cout<<lv[a.LOVE+1]-a.exp<<"exp可升至下一级"<<"\n\t\t\t\t\t攻击力:"<<a.true_fight<<"\n\t\t\t\t\t防御力:"<<a.true_blooked<<"\n\t\t\t\t\t金币:"<<a.Gold; system("pause"); goto Main; }
-
2025-9-10 13:08:52@
#include <iostream> #include <ctime> #include <cstring> #include <string> #include <cmath> #include <algorithm> #include <queue> #include <iomanip> #include <cstdio> #include <cstdlib> #include <vector> #include <stack> #include <set> #include <map> #include<stdlib.h> #include<stdio.h> #include<time.h> #include<string.h> #include<windows.h> #include<conio.h> using namespace std; int blood=100,attack=3; string weapon; string aaa[101]; int nnn=10,mmm=10,k,x=1,y=1,mercy=10; struct monster { int s,a,b; string name; }hudie; void jiazai() { printf("正在检查网络...\n0"); Sleep(150); system("cls"); printf("正在连接服务器...\n▊15"); Sleep(210); system("cls"); printf("加载资源中...\n█▎25"); Sleep(180); system("cls"); printf("加载资源中...\n██▊55"); Sleep(120); system("cls"); printf("加载资源中...\n███▌70"); Sleep(90); system("cls"); printf("加载资源中...\n███▊75"); Sleep(450); system("cls"); printf("正在加载剧情...\n████▌90"); Sleep(120); system("cls"); printf("正在加载怪兽...\n█████100"); Sleep(300); system("cls"); printf("正在进入新章节...\n█████100"); Sleep(900); system("cls"); } void SlowDisplay(char *p) { system("cls"); while(1) { if(*p!=0) printf("%c",*p++); else break; } system ("pause>nul"); } void texiao() { for(int i=1; i<=10; i++) { system("color 2f"); Sleep(10); system("color 0f"); Sleep(10); } } void out() { int i,j; for(i=1;i<=nnn;i++) { for(j=0;j<=mmm;j++) { cout<<aaa[i][j]<<" "; } cout<<endl; } return; } void fight(monster x) { cout<<"突然,"; cout<<x.name; cout<<"朝你冲了过来!!!\n"; system("pause"); cout<<"是否战斗? 1.是 2.否\n"; int q; cin>>q; if(q==1) { mercy--; while(blood>=0&&x.b>=0) { { bool flag=false; cout<<"你的血:"<<blood<<endl<<x.name<<"的血:"<<x.b<<endl; cout<<"1.攻击 2.闪避 3.特殊技能(暂未开发,请勿选3,否则默认为2)\n"; int q; cin>>q; if(q==1) { if(rand()%100<x.s) cout<<"敌人闪开了!!!\n"; else { cout<<"敌人被打中。。。\n"; x.b-=attack; }} else { cout<<"猜一个从1~10的数,3次机会,猜对即可闪避2回合。。。"; int xxx=rand()%10+1; int yyy,c=0; while(yyy!=xxx&&c<3) { cin>>yyy; if(yyy>xxx) { cout<<"大了!!!"; } if(yyy<xxx) { cout<<"小了!!!"; } c++; } if(yyy==xxx) { cout<<"闪避成功!!!\n"; flag=true; } else { cout<<"闪避失败!!!\n"; } } if(flag!=true) { cout<<"轮到敌人啦!!!\n"; if(q==1) blood-=x.a*2; else blood-=x.a; cout<<"你被打中。。。\n"; } } } if(blood<=0) { cout<<"you died!!!"<<endl; return; } else { cout<<"you won!!!"<<endl; return; } } else { mercy+=2; cout<<"you escape!!!\n"; } } bool judge(int x,int y) { if(x<1||y<0)return 0; if(x>10||y>10)return 0; if(aaa[x][y]=='*')return 0; return 1; } int main() { srand(time(NULL)); hudie.s=10; hudie.a=1; hudie.b=20; hudie.name="BUTTfly(蝴蝶)"; int t; while(t!=1) { printf("你好,欢迎来到暗黑诅咒游戏第二季Pavris的封印,如果你没玩第一季,赶紧去玩一下,要不然,你根本看不懂剧情!!!\n"); cout<<"主菜单:"<<endl; cout<<"》1.开始游戏《"<<endl<<"2.查看人物介绍"<<endl<<"3.查看更新日志"<<endl<<"4.查看新手攻略"<<endl<<"5.查看目录"<<endl; cin>>t; if(t==1) system("cls"); else if(t==3) { SlowDisplay("0.0.2 更完第一章和第二章一半\n"); SlowDisplay("0.0.3 更完前两章\n"); } else if(t==4) { SlowDisplay("合理打怪,跟着剧情走即可。。。\n"); } else if(t==2) { SlowDisplay("你:Frisk Black,Rick Black的儿子,18岁中二病青年,父母都死了,由爷爷,奶奶养,根本不知道自己其实是个法师。\n"); SlowDisplay("Crish:强大法师,打败了德沃拉,并封印了他,现任ZO国国王\n"); SlowDisplay("shiys:ZO国忠臣,预言家,法力也很强。\n"); SlowDisplay("Sean Moster:有着奇怪姓氏,有着神秘身世,你的好伙伴,跟Ivy是对龙凤胎。\n"); SlowDisplay("Ivy Moster:Sean他妹妹。\n"); SlowDisplay("Oliver Moster:龙凤胎的爷爷,性格古怪。\n"); SlowDisplay("德利特:你邻居,中年人,警察,他女儿被法师杀害,于是他热衷于捕杀法师,对法师有着深仇大恨。\n"); SlowDisplay("梅林:德利特儿子,20岁。\n"); SlowDisplay("佩刀杀人狂:杀人不眨眼的魔头。\n"); } else if(t==5) { SlowDisplay("第一章 坠落\n"); SlowDisplay("第二章 地下世界\n"); SlowDisplay("第三章 国王\n"); SlowDisplay("第四章 水晶国决斗场\n"); SlowDisplay("第五章 竹子国遗迹\n"); SlowDisplay("第六章 圣骷髅教堂和水晶球\n"); SlowDisplay("第七章 鬼屋逃生\n"); SlowDisplay("第八章 ???\n"); SlowDisplay("第九章 营救\n"); SlowDisplay("第十章 最后一刻\n"); } else { cout<<"ByeBye~"<<endl; return 0; }} printf("文字游戏:暗黑诅咒第二季(The Curse Of Darkness And The Seal Of Pavris Black)\n"); Sleep(1000); printf("出品人:drzo(teacherga)\n"); Sleep(1000); printf("版本:0.0.3\n"); Sleep(1000); system("pause"); system("cls"); jiazai(); texiao(); cout<<"查看剧情输1,否则跳过。"<<endl; int tt; cin>>tt; if(tt==1) { SlowDisplay("话说世界上分为两个人种,法师和人类,在中世纪两个人种就走上了不同的路,法师建立了法师地下世界,有竹子国,水晶国和ZO村,后来德沃拉出现,灭了竹子国,后来德沃拉被封印,ZO村变为了ZO国,而打败德沃拉的勇士Crish成为了ZO国国王。\n"); SlowDisplay("暗黑诅咒第一季所有剧情都发生在法师地下王国,而我们这一季的主人公将是一个地上的普通人类,也就是你,Frisk Black。\n"); system("pause"); } jiazai(); int q1; cout<<"现在请选择个武器:1.牙签 2.小石子 3.haobo8\n"; cin>>q1; if(q1==1) weapon="牙签"; else if(q1==2) weapon="小石子"; else weapon="haobo8"; SlowDisplay("drzo:很好,你现在武器选好了,还等什么,开始游戏吧!!!\n"); cout<<"祝你们游戏愉快,输入1开始\n"; int a; cin>>a; if(a==1) { SlowDisplay("第一章 坠落\n"); SlowDisplay("先介绍一下角色:\n"); SlowDisplay("Sean Moster:有着奇怪姓氏,有着神秘身世,你的好伙伴,跟Ivy是对龙凤胎。\n"); SlowDisplay("Ivy Moster:Sean他妹妹。\n"); SlowDisplay("Oliver Moster:龙凤胎的爷爷,性格古怪。\n"); SlowDisplay("德利特:你邻居,中年人,警察,他女儿被法师杀害,于是他热衷于捕杀法师,对法师有着深仇大恨。你还一直记着那恐怖的一天,你亲眼见到德利特女儿被一个无形的手扔起10米高,被摔死,据说是法师干的,但从未找到凶手。。。\n"); SlowDisplay("梅林:德利特儿子,20岁。\n"); SlowDisplay("而你——Frisk Black是个普通高中生,你父母5年前都去世了,你爸爸Rick Black是个神秘的人,你从来都没有见到过他,你母亲总安抚你说他会回来的,但是他永远都没回来,你恨他,他就是个无用之人,甚至不爱自己儿子,导致你一直没有父爱,直到5年前你父母都死了,你悲痛万分,只能由你爷爷奶奶抚养。\n"); SlowDisplay("你觉着你很普通,但真的如此吗?\n"); system("pause"); system("cls"); SlowDisplay("上午十点 图书馆 状态:良好 武器:"); cout<<weapon<<endl; SlowDisplay("你:tmd,作业实在太多了,老师是都在搞笑吗,我就想知道20张卷子2天怎么做完?!!\n"); SlowDisplay("Ivy抱着一堆书从个书架后走出,她说:我看你该认真学习。。。\n"); SlowDisplay("你想:像往常一样热爱学习。。。难道她从来没休息过吗?!\n"); SlowDisplay("你自己发着牢骚,一边寻找文献资料,你想:这图书馆真tm大,连本书都找不到。。。\n"); SlowDisplay("adsw来行走,*是书架,@是你,#是个神奇的东西: 按任意键继续。。。\n"); int i,j; aaa[1]="*@*********"; aaa[2]="* *"; aaa[3]="* * * * * *"; aaa[4]="* * * * * *"; aaa[5]="* *"; aaa[6]="* * * * * *"; aaa[7]="* * * * * *"; aaa[8]="* * * * * *"; aaa[9]="* *"; aaa[10]="*********#*"; out(); char c; for(;;) { c=getch(); system("cls"); if(c=='w') { if(judge(x-1,y)) { swap(aaa[x-1][y],aaa[x][y]); x--; } } if(c=='a') { if(judge(x,y-1)) { swap(aaa[x][y-1],aaa[x][y]); y--; } } if(c=='s') { if(judge(x+1,y)) { swap(aaa[x+1][y],aaa[x][y]); x++; } } if(c=='d') { if(judge(x,y+1)) { swap(aaa[x][y+1],aaa[x][y]); y++; } } out(); if(x==10&&y==9) { system("cls"); Sleep(2000); getch(); break; } } SlowDisplay("你慢慢走一个闪闪发光的东西,你发现是个普通的日记本,陈旧无比,封面都快要掉留下来,沾满灰尘,你拂去灰尘,只见上面画着个佩刀的符号,周围写着一圈大字:B L A C K,你好奇地翻开这本书,突然你的眼前一片白光,你感到这书开始剧烈发烫,你的手一不小心把这书丢在地上,这书一下子把地毯给烧焦了,你眼前仍白光一片,大量的光亮让你感到都快失明了。\n"); SlowDisplay("sean(Ivy哥哥)走了过来:你在干什么啊,你爷爷喊你快回家吃午饭!\n"); SlowDisplay("你立马收起来了书,你把所有刚刚的事情都告诉了Ivy和Sean,你们决定一起去你家研究一下那本书。。。\n"); SlowDisplay("你们到了你卧室里头,你再次打开了那本书,这次书变得更烫,热的迫使你松开手使书掉到了地板上,立马地板烧开了个大洞,而且洞越来越深,黑森森的看不清底。。。\n"); SlowDisplay("你:什么情况?!! 你往洞里喊了几声没有任何响应,突然白光再次在你眼前出现,你的背后有一双手把你推了下去,几声尖叫和几声哐当,你们坠落到了洞的底部!\n"); SlowDisplay("第一章 完\n"); jiazai(); SlowDisplay("第二章 国王\n"); SlowDisplay("你和兄妹两个一起落入深渊,落到洞底,里面空无一人十分黑暗而寂静,你在地上慢慢爬起,但疼痛感使你被迫再次摔倒在潮湿的地上,突然你摸到了一个东西,你一看,竟然是个人的头骨!你被吓得惊声尖叫,Sean和Ivy也被吓了一跳,原来你们站着的地上铺满了尸骸。。。你们在一个墓地里!\n"); fight(hudie); if(blood<=0) return 0; SlowDisplay("你:哎呀,原来就是个蝴蝶,虚惊一场。。。\n"); SlowDisplay("Ivy:咱们赶紧离开这里吧。。。我好怕~\n"); SlowDisplay("话音刚落,一把飞刀从你脸旁飞过,你吓得连忙躲开,一个1米8左右的戴着人骨面具的男子从阴影里走出。。。\n"); SlowDisplay("你:你。。。你是谁!?\n"); SlowDisplay("???:...\n"); SlowDisplay("你:快说你名字,否则我就不客气了!\n"); SlowDisplay("???:...\n"); SlowDisplay("???:...\n"); SlowDisplay("突然你背后的飞刀回旋了回来,你需要快速闪避!!!\n"); cout<<"猜一个从1~10的数,3次机会,猜对即可闪避。。。"; int xxx=rand()%10+1; int yyy,cc=0; while(yyy!=xxx&&cc<3) { cin>>yyy; if(yyy>xxx) { cout<<"大了!!!"; } if(yyy<xxx) { cout<<"小了!!!"; } cc++; } if(yyy==xxx) { cout<<"闪避成功!!!\n"; } else { cout<<"闪避失败!!!你死了!!!\n"; return 0; } } SlowDisplay("你:大家快跑!!!\n"); SlowDisplay("但是已经晚了,手持佩刀的人朝你们扑了过来,只听他用沙哑的声音默念道:就差一个灵魂了,我就能无敌了。。。\n"); SlowDisplay("突然你背后飞来那本日记本,正中面具男,把他砸晕在地,你们头也不回地跑掉了。。。\n"); system("pause"); SlowDisplay("下午五点 地下 状态:疲劳 武器:"); cout<<weapon<<endl; SlowDisplay("你们不知跑了多长时间,直到你们跑到一条河旁。。。\n"); SlowDisplay("你:让我理一下,首先我们在图书馆里拿到一本破日记本,然后在我卧室里烫了个洞直通地下,之后我们又不知为何掉了下去,就迎面遇上了个疯子杀人魔,最后我们发现这地下大得很,竟然地下连小溪都有,告诉我这一切都是梦。。。\n"); SlowDisplay("Sean:我们现在应该想想怎么离开这里,快看!那边有人!!!\n"); SlowDisplay("你:地下也有人?!\n"); SlowDisplay("你想去跟那个人交流一下,问下路,但你发现那个人手持长刀,身穿盔甲,你想:这人怕是在演戏,这哪里是冷兵器时代?!\n"); SlowDisplay("那人看到了你,眉头一皱,突然一条红光正射中你,你倒在地上无法动弹,之后你和Ivy和Sean都被绑了起来,扔进一个马车上,你自言自语道:莫非我穿越了?!怎么这个年代还有马车?!\n"); SlowDisplay("Ivy哭着说:我明白了。。。\n"); SlowDisplay("Sean害怕又焦急地问:你知道什么了?!!\n"); SlowDisplay("Ivy:我们到了法师世界了,刚刚那个人就是法师,要不然他能把Frisk隔空打倒,而且我在书中读到,法师自从中世纪就消失不见,因为他们自己建了个世界自己生存,所以他们还保留中世纪习俗,而现在我们被一群法师抓走了!!!\n"); SlowDisplay("第二章 完\n"); system("pause"); return 0; }
-
2025-9-10 13:01:47@
20081115
-
2025-9-9 16:10:08@
#include<bits/stdc++.h> #include<windows.h> #include<conio.h> #include<cstdio> #define random(a1,a2) rand()/(a2-a1+1)+a1 using namespace std; struct user { char name[10000]; char ch; int marketvip; int talk; int power_of_earth; int blood,Gold,exp,LOVE,angry,true_fight,true_blooked; }; struct computer { // char name[10000]; int blood,Gold,exp,true_fight,true_blooked,angry; }; user a; computer b; FILE *fin,*fout; int item[]={0,160,1500,13500,66000,160,1440,13500,125000,160,1400,14000,125000,1100000,1100000,4800000,4800000}; // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 int lv[1001]={0 , 0 , 10 , 25 , 100 , 200 , 400 , 500 , 1000 , 1600 , 2400 , 4000 , 6250 , 8750 , 10000 , 12500 , 15000 , 18000 , 22500 , 25000 , 30000 , 37500 , 50000 , 75000 , 125000}; int blood_[1001]={0 , 100 , 125 , 150 , 200 , 250 , 300 , 500 , 800 , 1250 , 1600 , 2000 , 2500 , 4000 , 6250 , 9750 , 12500 , 16000 , 18000 , 24000 , 32000 , 40000 , 48000 , 60000 , 80000 }; void start(); void game(); void out(string,float); void fight(); int main() { srand(int(time(NULL))); a.Gold=0; a.LOVE=1; a.exp=0; a.marketvip=0; a.talk=0; a.power_of_earth=0; for(int i=25;i<=600;i++) { lv[i]=(lv[i-1]*3-lv[i-2])-(lv[i-1]*3-lv[i-2])%10000; blood_[i]=(blood_[i-1]*3-blood_[i-2])-(blood_[i-1]*3-blood_[i-2])%10000; } for(int i=601;i<=1000;i++) blood_[i]=lv[i]=2000000000,blood_[i]-=400000000; cout<<"\t\t\t\t\t\t怪兽纪元\n"; cout<<"\n\n\n\n"; cout<<"\t\t\t\t\t\t1.开始新游戏\n"; cout<<"\t\t\t\t\t\t2.使用旧存档\n"; int say_in; cin>>say_in; if(say_in==1) { fout=fopen("Archive.Archive","wb"); fprintf(fout,"name\n1\n0\n0\n0\n0\n0\n0\n0\n"); fin=fopen("Archive.Archive","rb"); fscanf(fin,"%s%d%d%d%d%d%d%d",&a.name,&a.LOVE,&a.exp,&a.Gold,&a.true_fight,&a.true_blooked,&a.marketvip,&a.talk,&a.power_of_earth); fclose(fout); fclose(fin); start(); } else { fin=fopen("Archive.Archive","rb"); fscanf(fin,"%s%d%d%d%d%d%d%d%d",&a.name,&a.LOVE,&a.exp,&a.Gold,&a.true_fight,&a.true_blooked,&a.marketvip,&a.talk,&a.power_of_earth); fclose(fin); // out("你再取一个新名字吧",0.01); // cin>>a.name; // out("哦,"+a.name+",真是个好名字,开始你的复仇之旅吧!!!",0.08); game(); } } void start() { system("cls"); cout<<"\t\t\t\t\t\t怪兽纪元"; Sleep(1000); out("\n“XXX年,”\n",0.01); Sleep(500); out("“怪兽入侵S王国,”\n“战火四起,数千万人无家可归”",0.01); getchar(); out("\n......\n“整个王国陷入了绝望”",0.01); out("\n“而本国的公主也被怪兽之王附身,去往了一个小岛上...”",0.01); Sleep(1000); system("cls"); int x=GetSystemMetrics(SM_CXSCREEN); int y=GetSystemMetrics(SM_CYSCREEN); for(int i=25;i;i--) { SetCursorPos(rand()%x,rand()%y); Sleep(40); } Sleep(1000); out("你的耳旁响起了一个声音:\"你是与怪兽之王对战时被打伤的,你已经昏迷了十一年,你是唯一幸存的能拯救王国的人!它们去往了骷髅岛那个与世隔绝的地方,国王希望你能够去救公主,你是我们国家的希望!!!\"\n",0.01); getch(); Sleep(2000); system("cls"); out("你抬头看了看四周,这是个岛,海外围裹着一层强力台风,里面是危险的丛林,旁边旧损的牌子上写着Skull Island(骷髅岛)...\n",0.01); Sleep(1000); out("勇者,请输入你的名字\n",0.01); cin>>a.name; system("cls"); out("哦,",0.08); out(a.name,0.08); out(",真是个好名字,开始你的旅途吧!!!",0.08); Sleep(200); game(); } void out(string str,float time) { for(int i=0;i<str.size();i++) { Sleep(time*1000); cout<<str[i]; } } short fight(string name,int blood,int fight,int blooked) { int WayToFight,falseblood=blood,angry=0; while(true) { a.angry++,angry++; system("cls"); cout<<"你的血量:"<<a.blood<<"\t敌方血量:"<<blood<<"\n你的攻击力:"<<a.true_fight<<"\t敌方攻击力:"<<fight<<"\n你的防御力:"<<a.true_blooked<<"\t敌方防御力:"<<blooked<<"\n我方回合:\n1.普通攻击\t2.怒气攻击(怒气:"<<a.angry<<"/5"; if(a.angry<5) cout<<",暂时不够"; cout<<")\t3.逃跑\n"; cin>>WayToFight; if(WayToFight==1) if(random(1,5)==1) { out("你打出了暴击,对"+name+"造成了",0.06); if(a.true_fight>blooked) { cout<<(a.true_fight-blooked)*2; blood-=(a.true_fight-blooked)*2; } else cout<<0; out("点伤害",0.01); } else { out("你打掉了他",0.01); if(a.true_fight>blooked) { cout<<(a.true_fight-blooked); blood-=(a.true_fight-blooked); } else cout<<0; out("滴血",0.01); } if(WayToFight==2) if(a.angry>4) { a.angry-=5; out("你使用了怒气攻击,敌方扣了",0.01); if(a.true_fight>blooked) { cout<<(a.true_fight-blooked)*5; blood-=(a.true_fight-blooked)*5; } else cout<<0; out("滴血",0.01); } if(WayToFight==3) if(blood*1.0/falseblood<0.4 and random(1,3)<3) if(random(1,3)==1) { out(a.name,0.06); out(":I'm out of here.",0.06); return 2; } else if(random(1,2)==1) { out(a.name,0.01); out(":别拖我后腿。",0.01); return 2; } else { out(a.name,0.01); out(":我先走一步",0.01); return 2; } else { out(name,0.01); out(":想得美!",0.01); } if(blood<=0) return 1; Sleep(600); system("cls"); cout<<"你的血量:"<<a.blood<<"\t敌方血量:"<<blood<<"\n你的攻击力:"<<a.true_fight<<"\t敌方攻击力:"<<fight<<"\n你的防御力:"<<a.true_blooked<<"\t敌方防御力:"<<blooked<<"\n敌方回合:\n"; if(blood*1.0/falseblood<0.01) { if(rand()%100<40) { out(name+":我先走一步。",0.01); return 2; } } else if(angry>4) { angry-=5; out("敌方使用了怒气攻击,你扣了",0.01); if(fight>a.true_blooked) { cout<<(fight-a.true_blooked)*5; a.blood-=(fight-a.true_blooked)*5; } else cout<<0; out("滴血",0.01); } else { if(random(1,5)==1) { out("他打出了暴击,对你造成了",0.06); if(fight>a.true_blooked) { cout<<(fight-a.true_blooked)*2; a.blood-=(fight-a.true_blooked)*2; } else cout<<0; out("点伤害",0.01); } else { out("他打掉了你",0.01); if(fight>a.true_blooked) { cout<<(fight-a.true_blooked); a.blood-=(fight-a.true_blooked); } else cout<<0; out("滴血",0.01); } } if(a.blood<=0) return 0; } } bool boss(int blood,int fight,int blooked) { int WayToFight,falseblood=blood,angry=0; while(true) { a.angry++,angry++; system("cls"); cout<<"你的血量:"<<a.blood<<"\t怪兽之王血量:"<<blood<<"\n你的攻击力:"<<a.true_fight<<"\t怪兽之王攻击力:"<<fight<<"\n你的防御力:"<<a.true_blooked<<"\t怪兽之王防御力:"<<blooked<<"\n我方回合:\n1.普通攻击\t2.怒气攻击(怒气:"<<a.angry<<"/5"; if(a.angry<5) cout<<",暂时不够"; cout<<")"; cin>>WayToFight; if(WayToFight==1) if(random(1,5)==1) { out("你打出了暴击,对怪兽之王造成了",0.06); if(a.true_fight>blooked) { cout<<(a.true_fight-blooked)*2; blood-=(a.true_fight-blooked)*2; } else cout<<0; out("点伤害",0.01); } else { out("你打掉了他",0.01); if(a.true_fight>blooked) { cout<<(a.true_fight-blooked); blood-=(a.true_fight-blooked); } else cout<<0; out("滴血",0.01); } if(WayToFight==2) if(a.angry>4) { a.angry-=5; out("你使用了怒气攻击,敌方扣了",0.01); if(a.true_fight>blooked) { cout<<(a.true_fight-blooked)*5; blood-=(a.true_fight-blooked)*5; } else cout<<0; out("滴血",0.01); } if(blood<=0) return true; Sleep(600); system("cls"); cout<<"你的血量:"<<a.blood<<"\t怪兽之王血量:"<<blood<<"\n你的攻击力:"<<a.true_fight<<"\t怪兽之王攻击力:"<<fight<<"\n你的防御力:"<<a.true_blooked<<"\t怪兽之王防御力:"<<blooked<<"\n敌方回合:\n"; if(angry>4) { angry-=5; out("怪兽之王使用了怒气攻击,你扣了",0.01); if(fight>a.true_blooked) { cout<<(fight-a.true_blooked)*5; a.blood-=(fight-a.true_blooked)*5; } else cout<<0; out("滴血",0.01); } else { if(random(1,5)==1) { out("他打出了暴击,对你造成了",0.06); if(fight>a.true_blooked) { cout<<(fight-a.true_blooked)*2; a.blood-=(fight-a.true_blooked)*2; } else cout<<0; out("点伤害",0.01); } else { out("他打掉了你",0.01); if(fight>a.true_blooked) { cout<<(fight-a.true_blooked); a.blood-=(fight-a.true_blooked); } else cout<<0; out("滴血",0.01); } } if(a.blood<=0) return false; } } void game() { string his; int fightflag,TFeasy,choose; a.blood=blood_[a.LOVE]; Main: if(a.exp>=lv[a.LOVE+1]) { while(a.exp>=lv[a.LOVE+1]) a.exp-=lv[++a.LOVE]; out("\n你的等级增加了!",0.01); } a.angry=0; system("cls"); out("你想去做什么:\n",0.01); if(a.true_fight!=0 or a.true_blooked!=0) cout<<"1.探索\t2.商店\t3.存档\t4.查看\t5.开挂\t"; cout<<"6.对话\t"; if(a.power_of_earth) { cout<<"7.救公主\n"; } cout<<'\n'; cin>>a.ch; switch(a.ch) { case '1': if(a.true_fight!=0 or a.true_blooked!=0) goto steet; break; case '2': if(a.true_fight!=0 or a.true_blooked!=0) goto supermarket; break; case '3': if(a.true_fight!=0 or a.true_blooked!=0) { a.blood=blood_[a.LOVE]; fout=fopen("Archive.Archive","wb"); fprintf(fout,"%s\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n",a.name,a.LOVE,a.exp,a.Gold,a.true_fight,a.true_blooked,a.marketvip,a.talk,a.power_of_earth); fclose(fout); } break; case '4': if(a.true_fight!=0 or a.true_blooked!=0) goto info_; break; case '5': if(a.true_fight!=0 or a.true_blooked!=0) { out("输入秘钥:",0.01); cin>>choose; if(choose==20081115) { out("尊贵的VIP,请享受我们的服务.",0.01); out(".",0.333); out(".",0.333); Sleep(1000); system("cls"); cout<<"抽取资源中..."; a.blood=99999999; a.LOVE=20; a.Gold=99999999; a.true_fight=9999999; a.true_blooked=99999999; a.marketvip=1; a.talk=1; a.power_of_earth=1; Sleep(1000); system("cls"); cout<<"保存中..."; fout=fopen("Archive.Archive","wb"); fprintf(fout,"%s\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n",a.name,a.LOVE,a.Gold,a.exp,a.true_fight,a.true_blooked,a.marketvip,a.talk,a.power_of_earth); Sleep(1000); } } break; case '6': if(!a.talk) { out("'上一位'勇者:\"你是来救公主的吧?!我劝你小心一点,我之前来的十个勇者都死了,你现在没有攻击力、防御力,是连史莱姆都打不败的,我助你一臂之力,送你一瓶增幅药水,加油吧!\"\n",0.01); system("PAUSE"); system("cls"); out("你已获得6点攻击力!",0.01); a.talk=1; a.true_fight=6; Sleep(200); } else { if(rand()%10==0) { out("'上一位'勇者:\"对了,我打听到一个消息,只要你得到了大地结晶,你就能开启通往关押公主的地方的门,至于怎么获得?......我尚不知道。\"\n",0.01); system("PAUSE"); } else out("'上一位'勇者:\"加油!你是我们的希望!\"\n",0.01); } break; case '7': if(a.power_of_earth) { out("怪兽之王:\"又一个不自量力的人,敢来挑战我?!\"\n",0.01); out(a.name,0.01); out(":\"哼,我今天就得把你这个孽畜斩下,救出公主!!!\"\n",0.01); out("怪兽之王:\"噢,原来是老熟人啊。想救公主?!(冷笑了两声)那得看你的本事!!!\"\n",0.01); system("pause"); system("CLS"); out("你遭遇了怪兽之王。",0.01); if(boss(1000000,500000,500000)) { out("怪兽之王已被斩杀,勇者",0.01); out(a.name,0.01); out("救出了S国的公主。\n国王为了感谢勇者,便把公主许配给了",0.01); out(a.name,0.01); out("。\n从此,勇者和公主过上了幸福的生活\n(本游戏已完结,感谢游玩)",0.01); exit(0);//人人人人人人人人人人人人人人人人人人人人人人人人人人人人人人人入人入人人人人人人人人人人人人人入人人人人人人人人人人人人人人人人人人人人人人人人人人 } else { cout<<"\t\t\t\t\t\t失败"; system("start 怪兽纪元.exe"); } } break; } goto Main; steet: system("cls"); cout<<"1.寻宝\t2.挑战\n"; cin>>a.ch; switch(a.ch) { case '1': goto aaaaa; case '2': goto fight; default: goto Main; } aaaaa: system("cls"); Sleep(2000); b.Gold=rand()%50; a.Gold+=b.Gold; out("你捡到了",0.01); cout<<b.Gold; out("枚金币。",0.01); Sleep(10); goto Main; fight: system("cls"); if(a.LOVE<2) TFeasy=1; else if(a.LOVE<3) TFeasy=2; else if(a.LOVE<4) TFeasy=3; else if(a.LOVE<6) TFeasy=4; else if(a.LOVE<8) TFeasy=5; else if(a.LOVE<10) TFeasy=6; else if(a.LOVE<12) TFeasy=7; else if(a.LOVE<15) TFeasy=8; else if(a.LOVE<18) TFeasy=9; else if(a.LOVE<24) TFeasy=10; else TFeasy=11; switch(TFeasy>1?(TFeasy-rand()%4-1):(rand()%4+TFeasy-2)) { case 0: his ="史莱姆"; b.Gold=random(20,40); b.exp=10; b.blood=50; b.true_fight=5; b.true_blooked=1; break; case 1: his="食人花"; b.Gold=random(50,100); b.exp=25; b.blood=100; b.true_fight=60; b.true_blooked=20; break; case 2: his="红蝙蝠"; b.Gold=random(160,400); b.exp=50; b.blood=400; b.true_fight=40; b.true_blooked=60; break; case 3: his="灵骷髅"; b.Gold=random(800,1500); b.exp=250; b.blood=600; b.true_fight=250; b.true_blooked=80; case 4: his="巨人"; b.Gold=random(3000,5000); b.exp=800; b.blood=800; b.true_fight=800; b.true_blooked=80; break; case 5: his="金刚"; b.Gold=random(8000,10000); b.exp=2500; b.blood=1500; b.true_fight=1500; b.true_blooked=200; break; case 6: his="食人蚯蚓"; b.Gold=random(10000,40000); b.exp=12500; b.blood=15000; b.true_fight=2000; b.true_blooked=2000; break; case 7: his="朽灵法师"; b.Gold=random(60000,125000); b.exp=100000; b.blood=30000; b.true_fight=10000; b.true_blooked=6000; break; case 8: his="远古守卫"; b.Gold=random(150000,750000); b.exp=1250000; b.blood=80000; b.true_fight=10000; b.true_blooked=25000; break; case 9: his="巨龙"; b.Gold=random(1000000,3000000); b.exp=1250000; b.blood=100000; b.true_fight=50000; b.true_blooked=10000; break; case 10: his="大地之灵"; b.Gold=random(6000000,20000000); b.exp=3000000; b.blood=1000; b.true_fight=200000; b.true_blooked=400000; break; } out("你遭遇了"+his+",是(1)否(2)攻击?",0.01); cin>>a.ch; if(a.ch==49) { fightflag=fight(his,b.blood,b.true_fight,b.true_blooked); if(fightflag==1) { out("\n\t\t\t\t胜利\n",0.01); a.Gold+=b.Gold,a.exp+=b.exp; if(his=="大地之灵" and !a.power_of_earth) { out("恭喜你获得了大地结晶!\0",0.01); system("pause"); a.power_of_earth=1; } } else if(fightflag==0) { cout<<"\n\t\t\t\t失败\n"; Sleep(100); system("start 怪兽纪元.exe"); exit(0); } } goto Main; supermarket: system("cls"); out("神秘老人:你要买什么?\n",0.01); Sleep(200); cout<<"1.一瓶劣质经验药水(增长20经验)¥160\n2.一瓶低级经验药水(增长200经验)¥1500\n3.一瓶中级经验药水(增长2000经验)¥13500\n4.一瓶高级经验药水(增长10000经验)¥66000\n"; cout<<"5.一瓶劣质攻击药水(增长10攻击力)¥160\n6.一瓶低级攻击药水(增长100攻击力)¥1440\n7.一瓶中级攻击药水(增长1000攻击力)¥13500\n8.一瓶高级攻击药水(增长10000攻击力)¥125000\n"; cout<<"9.一瓶劣质防御药水(增长8防御力)¥160\n10.一瓶低级防御药水(增长80防御力)¥1400\n11.一瓶中级防御药水(增长875防御力)¥14000\n12.一瓶高级防御药水(增长7500防御力)¥125000\n"; if(a.marketvip) { cout<<"13.一瓶一阶极品攻击药水(增长100000攻击力)¥1100000\n14.一瓶一阶极品防御药水(增长90000防御力)¥1100000\n"; cout<<"15.一瓶最高阶极品攻击药水(增长500000攻击力)¥4800000\n16.一瓶最高阶极品防御药水(增长480000防御力)¥4800000\n"; } if(!a.marketvip) cout<<"999.高级通行证(可购买高级增幅药水)¥999999\n"; cout<<"0.返回\n"; cin>>choose; if(!choose) { out("神秘老人:慢走!",0.01); Sleep(200); goto Main; } if(choose==999) { if(a.marketvip) out("神秘老人:你不是已经办了么?\n",0.01); else { if(a.Gold<999999) out("神秘老人:钱不够,办不了!\n",0.01); else { a.Gold-=999999; a.marketvip=true; out("神秘老人:恭喜你能购买新物品了!!!\n",0.01); } } } else if(choose>16) out("神秘老人:没有这件商品!\n",0.01); else if(!a.marketvip and choose>12) out("神秘老人:没有这件商品!\n",0.01); else if(a.Gold<item[choose]) out("神秘老人:钱不够,买不了!\n",0.01); else { out("神秘老人:你已获得增幅!\n",0.06); Sleep(200); switch(choose) { case 1: a.exp+=20,a.Gold-=160; break; case 2: a.exp+=200,a.Gold-=1500; break; case 3: a.exp+=2000,a.Gold-=13500; break; case 4: a.exp+=10000,a.Gold-=66000; break; case 5: a.true_fight+=10,a.Gold-=160; break; case 6: a.true_fight+=100,a.Gold-=1440; break; case 7: a.true_fight+=1000,a.Gold-=13500; break; case 8: a.true_fight+=10000,a.Gold-=125000; break; case 9: a.true_blooked+=8,a.Gold-=160; break; case 10: a.true_blooked+=80,a.Gold-=1400; break; case 11: a.true_blooked+=875,a.Gold-=14000; break; case 12: a.true_blooked+=7500,a.Gold-=125000; break; if(a.marketvip) { case 13: a.true_fight+=100000,a.Gold-=1100000; break; case 14: a.true_blooked+=90000,a.Gold-=1100000; break; case 15: a.true_fight+=500000,a.Gold-=4800000; case 16: a.true_blooked+=480000,a.Gold-=4800000; } } } goto supermarket; info_: system("cls"); Sleep(100); cout<<"\n\t\t\t\t\t名字:"<<a.name<<"\n\n\t\t\t\t\t目前血量:"<<a.blood<<"/"<<blood_[a.LOVE]<<"\n\t\t\t\t\t等级:"<<a.LOVE<<"\n\t\t\t\t\t还差"; cout<<lv[a.LOVE+1]-a.exp<<"exp可升至下一级"<<"\n\t\t\t\t\t攻击力:"<<a.true_fight<<"\n\t\t\t\t\t防御力:"<<a.true_blooked<<"\n\t\t\t\t\t金币:"<<a.Gold; system("pause"); goto Main; }
-
2025-9-4 13:16:39@
#include<bits/stdc++.h> using namespace std; int main(){ long long a,b; scanf("%lld%lld",&a,&b); if(a + b >= -2147483648 && a + b <= 2147483647) printf("No"); else printf("Yes"); return 0; }
-
2025-9-4 13:12:22@
#include<iostream> using namespace std; int main(){ long long n; cin >> n; cout << n * n - 1 << endl; return 0; }
-
2025-7-26 10:44:54@
谁有时间教我一道题?“出租车计费”那道题 @@苏芷萱
🤣 2 -
2025-7-13 15:59:14@
HI,在吗?
👍 1🤔 1 -
2025-7-12 17:35:37@
你们在吗?
-
2025-6-26 12:21:00@
#include<bits/stdc++.h> #include<windows.h> using namespace std; int main(){ long long a=2; system("color 2f"); for(int o=0;o<=5;++o){ if(a==0) cout<<"\n抽奖次数已用完,感谢参与!"; printf("==抽奖游戏==\n欢迎来玩抽奖游戏!\n输入一个2000内整数一个空格一个a到m的字母\n有奖有罚!\n您有%lld次机会\n请抽奖:\n",a+1); long long l; char v; cin>>l>>v; for(int i=1;i<=l;++i){ cout<<v<<" "; Sleep(0.9999999999999986); ++v; if(v=='n') v='a'; } if(v=='a') cout<<"真挺好"<<" "<<"我讲两个笑话"; if(v=='b') cout<<"运气不好"<<" "<<"大嘴巴子"; if(v=='c') cout<<"运气特不好"<<" "<<"戳你的心"; if(v=='d'){ cout<<"还行"<<" "<<"再来一"; ++a; } if(v=='i') cout<<"挺好"<<" "<<"借书一天"; if(v=='e') cout<<"很遗憾"<<" "<<"空"; if(v=='f') cout<<"运气不好"<<" "<<"二十个蹲起"; if(v=='g') cout<<"运气不好"<<" "<<"蛙跳10次"; if(v=='h') cout<<"运气好"<<" "<<"看我跳舞"; if(v=='j') cout<<"跳舞"; if(v=='k') cout<<"运气特不好"<<" "<<"骂自己"; if(v=='l') cout<<"运气不好"<<" "<<"装自己可爱"; if(v=='m'){ cout<<"还行"<<" "<<"再来一"; ++a; } cout<<"\n"; --a; } return 0; } //抽奖游戏
- 1
信息
- ID
- 1202
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 1
- 标签
- 递交数
- 3
- 已通过
- 0
- 上传者