- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 RPG 统计代码有点问题。我希望人们使用 6 个基本属性(力量、敏捷、体质、智力、智慧和魅力),最小值为 10。创建角色时,我希望他们有 15 点可以使用,并且在我的代码,一切正常,除非你在到达最后一个统计数据之前用完了要放置的点。假设您将所有 15 点都投入力量。显示屏显示您将拥有 25 力量、32478493 敏捷、-42734627 体质、-1 智力等(这些不是确切数字,只是看起来像的示例。)这是代码。
字符创建.h
#ifndef CharCreate_H
#define CharCreate_H
#include<fstream>
#include<string>
using namespace std;
int charcreate(){
fstream file;
char gender, choice;
string name, dummy;
int points;
int str, dex, con, intel, wis, cha;
float level;
double experience;
level = 1;
experience = 0;
ofstream myFile;
myFile.open ("T:\\character.txt");
system("color 2");
cout << "Welcome to the character creator." << endl;
genderchoice:cout << "First, are you male or female? (M/F)" << endl;
cin >> gender;
system("cls");
if (gender == 'M' || gender == 'm'){
cout << "You're male? (Y/N)" << endl;
cin >> choice;
system("cls");
if (choice == 'Y' || choice == 'y'){
cout << "Great!" << endl;
goto name;
} else if (choice == 'N' || choice == 'n'){
goto genderchoice;
}
} else if (gender == 'F' || gender == 'f'){
cout << "You're female? (Y/N)" << endl;
cin >> choice;
system("cls");
if (choice == 'Y' || choice == 'y'){
cout << "Great!" << endl;
goto name;
} else if (choice == 'N' || choice == 'n'){
goto genderchoice;
}
//------------------------------------------------------------------------------
name:system("cls");
system("color 3");
cout << "What is your name, traveler?" <<endl;
getline(cin,dummy);
getline(cin, name);
cout << "" << endl;
cout << "Your name is " << name << "? (Y/N)" << endl;
cin >> choice;
if (choice == 'Y' || choice == 'y'){
system("cls");
cout << "Greetings, " << name << "!" << endl;
} else if (choice == 'N' || choice == 'n'){
system("cls");
cout << "You must provide your name, stranger." << endl;
goto name;
}
//------------------------------------------------------------------------------
stats:system("cls");
system("color 4");
cout << "You have 6 stats to deal with in this game, and 15 points" << endl;
cout << "to allocate between them all." << endl;
cout << "These are: Strength (STR), Dexterity (DEX), Constitution (CON)," << endl;
cout << "Intelligence (INT), Wisdom (WIS), and Charisma (CHA)." << endl;
cout << "Continue: C" << endl;
cout << "Help: H" << endl;
cin >> choice;
if (choice == 'C' || choice == 'c'){
attrib:points = 15;
str:cout << "You have 10 Strength. How many more points do you wish to add?" << endl;
cin >> str;
points = points - str;
if (str > points > 15){
cout << "Not enough points!" << endl;
str = str - points;
goto str;
} else if (str == points){
cout << "Are you sure you want to put all of your points here?" << endl;
cin >> choice;
if (choice == 'Y' || choice == 'y') {
goto fin;
} else if (choice == 'N' || choice == 'n'){
goto str;
} else if (str < points){
goto dex;
}
}
cout << "Remaining points: " << points;
cout << "" << endl;
str = str + 10;
cout << "You have " << str << " Strength" << endl;
system("pause");
system("cls");
dex:cout << "You have 10 Dexterity. How many more points do you wish to add?" << endl;
cin >> dex;
points = points - dex;
if (dex > points > 15){
cout << "Not enough points!" << endl;
dex = dex - points;
goto dex;
} else if (dex == points){
cout << "Are you sure you want to put all of your points here?" << endl;
cin >> choice;
if (choice == 'Y' || choice == 'y') {
goto fin;
} else if (choice == 'N' || choice == 'n'){
goto dex;
} else if (dex < points){
goto con;
}
}
cout << "Remaining points: " << points;
cout << "" << endl;
dex = dex + 10;
cout << "You have " << dex << " Dexterity" << endl;
system("pause");
system("cls");
con:cout << "You have 10 Constitution. How many more points do you wish to add?" << endl;
cin >> con;
points = points - con;
if (con > points > 15){
cout << "Not enough points!" << endl;
con = con - points;
goto con;
} else if (con == points){
cout << "Are you sure you want to put all of your points here?" << endl;
cin >> choice;
if (choice == 'Y' || choice == 'y') {
goto fin;
} else if (choice == 'N' || choice == 'n'){
goto con;
} else if (con < points){
goto intel;
}
}
cout << "Remaining points: " << points;
cout << "" << endl;
con = con + 10;
cout << "You have " << con << " Constitution" << endl;
system("pause");
system("cls");
intel:cout << "You have 10 Intelligence. How many more points do you wish to add?" << endl;
cin >> intel;
points = points - intel;
if (intel > points > 15){
cout << "Not enough points!" << endl;
intel = intel - points;
goto intel;
} else if (intel == points){
cout << "Are you sure you want to put all of your points here?" << endl;
cin >> choice;
if (choice == 'Y' || choice == 'y') {
goto fin;
} else if (choice == 'N' || choice == 'n'){
goto intel;
} else if (intel < points){
goto wis;
}
}
cout << "Remaining points: " << points;
cout << "" << endl;
intel = intel + 10;
cout << "You have " << intel << " Intelligence" << endl;
system("pause");
system("cls");
wis:cout << "You have 10 Wisdom. How many more points do you wish to add?" << endl;
cin >> wis;
points = points - wis;
if (wis > points > 15){
cout << "Not enough points!" << endl;
wis = wis - points;
goto wis;
} else if (wis == points){
cout << "Are you sure you want to put all of your points here?" << endl;
cin >> choice;
if (choice == 'Y' || choice == 'y') {
goto fin;
} else if (choice == 'N' || choice == 'n'){
goto wis;
} else if (con < points){
goto cha;
}
}
cout << "Remaining points: " << points;
cout << "" << endl;
wis = wis + 10;
cout << "You have " << wis << " Wisdom" << endl;
system("pause");
system("cls");
cha:cout << "You have 10 Charisma. How many more points do you wish to add?" << endl;
cin >> cha;
points = points - cha;
if (cha > points == 15){
cout << "Not enough points!" << endl;
cha = cha - points;
goto cha;
} else if (cha == points){
cout << "Are you sure you want to put all of your points here?" << endl;
cin >> choice;
if (choice == 'Y' || choice == 'y') {
goto fin;
} else if (choice == 'N' || choice == 'n'){
goto cha;
} else if (con < points){
goto fin;
}
}
cout << "Remaining points: " << points;
cout << "" << endl;
cha = cha + 10;
cout << "You have " << cha << " Charisma." << endl;
system("pause");
system("cls");
fin:cout << "Your stats are:" << endl;
cout << "Strength: " << str << endl;
cout << "Dexterity: " << dex << endl;
cout << "Constitution: " << con << endl;
cout << "Intelligence: " << intel << endl;
cout << "Wisdom: " << wis << endl;
cout << "Charisma: " << cha << endl;
cout << "Are these correct? (Y/N)" << endl;
cin >> choice;
cout << "" << endl;
if (choice == 'Y' || choice == 'y'){
cout << "Congratulations, you have successfully finished your character." << endl;
} else if (choice == 'N' || choice == 'n')
goto attrib;
}
} else if (choice == 'H' || choice == 'h'){
cout << "Strength is how easily you can crush a tomato." << endl;
cout << "Dexterity is how easily you can handle a tomato with your hands." << endl;
cout << "Constitution is how easily you can eat a bad tomato." << endl;
cout << "Intelligence is knowing that tomato is a fruit." << endl;
cout << "Wisdom is not putting tomato in a fruit salad." << endl;
cout << "Charisma is selling a tomato-based fruit salad." << endl;
system("pause");
goto stats;
}
myFile << "Name: " << name << "\n";
myFile << "Gender: " << gender << "\n";
myFile << "\n";
myFile << "Level: " << level << "\n";
myFile << "Experience: " << experience << "\n";
myFile << "\n";
myFile << "Strength: " << str << "\n";
myFile << "Dexterity: " << dex << "\n";
myFile << "Constitution: " << con << "\n";
myFile << "Intelligence: " << intel << "\n";
myFile << "Wisdom: " << wis << "\n";
myFile << "Charisma: " << cha << "\n";
myFile.close();
}
#endif
主要.cpp
#include <cstdlib>
#include <iostream>
#include "CharCreate.h"
using namespace std;
int main(int argc, char *argv[])
{
charcreate();
system("PAUSE");
return EXIT_SUCCESS;
}
如何解决点数用完后数字乱码的问题?如果有帮助,我正在运行 Bloodshed Dev C++ 作为编译器,因为这是我们在大学必须使用的编译器。
最佳答案
在 C++ 中,如果您不为变量设置值,它将包含当时恰好存在的任何随机数据。您将要在开始时将每个统计数据初始化为 10(或一些合理的默认值)。
关于c++ - RPG 统计问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27042731/
我目前正在学习数据挖掘,有以下问题。 机器学习和数据挖掘之间有什么关系? 我发现许多数据挖掘技术都与统计相关,而我“听说”数据挖掘与机器学习有很多关系。所以我的问题是:机器学习与统计学密切相关吗? 如
我有很多表的数据,例如: event_id player finish 1 a 1 1 b 2 1 c
我对 http_status_module 提供的统计数据感兴趣 特别是上游部分的统计数据。 http://nginx.org/en/docs/http/ngx_http_status_module.
除了 Cluster MBean 之外,是否有任何可以在 Akka (Java) 中启用的内置 JMX 公开监控/统计信息?我看过 Typesafe Console,但由于它需要许可证才能用于从多个节
我正在尝试在我的程序中使用“usage”统计信息来获取类似于 time 的数据工具。但是,我很确定我做错了什么。这些值似乎是正确的,但有时可能有点奇怪。我没有在网上找到好的资源。有人知道如何做得更好吗
我有一个带有统计表的 MySQL 数据库。我想以年历、月度的形式输出数据。对于没有点击率的几个月,我想花费一个“空”DIV。有两个ID。 $query = mysqli_query($db,"SELE
设置: 问题是经典概率问题的复杂形式: 70 colored balls are placed in an urn, 10 for each of the seven rainbow colors.
有哪些 Ruby gem 可以执行数据处理? 最佳答案 我知道有 3 种从 Ruby 访问 R 的方法: RinRuby RSRuby 通过 Rserve-Ruby-Client 预约 RinRuby
背景 图像领域内的一个国内会议快要召开了,要发各种邀请邮件,之后要录入、统计邮件回复(参会还是不参会等)。如此重要的任务,老师就托付给我了。ps: 统计回复邮件的时候,能知道谁参会或谁不参会。
我正在添加用户输入的几个数字并将它们添加到数组列表中。 到目前为止我的代码: package project143; import java.util.*; /** * @author -- */
正如标题所示,我需要做的是在各种 iO/Android/Windows 应用程序中跟踪各种用户事件 - 例如点击、滑动、在页面上花费的时间等。 这些应用程序基于响应式 HTML/CSS/JS,并具有简
我希望计算 HTML 表中每个唯一值的实例数,并在其自己的表中返回结果。该表是根据用户的文本输入生成的。例如,用户输入可能如下所示: Report 46 Bob Marley 4/20/2
如何使用 PHP 计算数字数组的 z 分数?我需要计算 z 分数,然后找到百分位数 (CDF)!我可以使用哪些 PHP 函数?谢谢! 最佳答案 以下代码将给出 CDF 的良好近似值(Abramowit
我只是想知道是否可以计算 GitHub 上空存储库的总数。 如果不适合所有用户,可以为自己做吗? 编辑 我已经尝试过size:0搜索,但似乎返回了很多包含数据的存储库。采用 size:0..1 之类的
public class Scanner { private HtmlProcessor hp; private String baseUrl; private int ste
我正在使用 Mule ESB 3.4。我想开发一个自定义 Java 组件来计算流收到的请求数量。流程将例如像这样: http inbound-endpoint -> counter -> vm-out
我喜欢借助 GitHub API 来统计存储库中所有开放的拉取请求和问题。我发现 API 端点 /repos/:owner/:repo 结果包含 open_issues 属性。然而,这是问题和拉取请求
如何使用 PHP 计算数字数组的 z 分数?我需要计算 z 分数,然后找到百分位数 (CDF)!我可以使用哪些 PHP 函数?谢谢! 最佳答案 以下代码将给出 CDF 的良好近似值(Abramowit
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我正在尝试以编程方式获取搜索字词列表的 Google 新闻搜索结果计数(即有多少个结果),但仅限于过去 1 年。使用用户界面搜索时,结果计数仅出现在常规搜索中,但在“工具 > 最近 > 过去一年”下时
我是一名优秀的程序员,十分优秀!