Skip to content

Commit

Permalink
添加项目文件。
Browse files Browse the repository at this point in the history
  • Loading branch information
CJYKK authored and CJYKK committed Jun 27, 2021
1 parent 253a773 commit aec8bb9
Show file tree
Hide file tree
Showing 6 changed files with 465 additions and 0 deletions.
31 changes: 31 additions & 0 deletions 猜数重制版.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31410.357
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "猜数重制版", "猜数重制版\猜数重制版.vcxproj", "{F6B4440B-996F-4ADC-B58B-68978369A6BC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F6B4440B-996F-4ADC-B58B-68978369A6BC}.Debug|x64.ActiveCfg = Debug|x64
{F6B4440B-996F-4ADC-B58B-68978369A6BC}.Debug|x64.Build.0 = Debug|x64
{F6B4440B-996F-4ADC-B58B-68978369A6BC}.Debug|x86.ActiveCfg = Debug|Win32
{F6B4440B-996F-4ADC-B58B-68978369A6BC}.Debug|x86.Build.0 = Debug|Win32
{F6B4440B-996F-4ADC-B58B-68978369A6BC}.Release|x64.ActiveCfg = Release|x64
{F6B4440B-996F-4ADC-B58B-68978369A6BC}.Release|x64.Build.0 = Release|x64
{F6B4440B-996F-4ADC-B58B-68978369A6BC}.Release|x86.ActiveCfg = Release|Win32
{F6B4440B-996F-4ADC-B58B-68978369A6BC}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B1F647BB-00C6-4878-9EF7-6E21DED1FE3E}
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions 猜数重制版/resource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by 猜数重制版.rc

// 新对象的下一组默认值
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
135 changes: 135 additions & 0 deletions 猜数重制版/猜数重制版.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
//各种头文件和将命名空间用关键字namespace来定义
#include <iostream>
#include <cstdlib>
#include <string>
#include <time.h>
#include <fstream>
#include <conio.h>
using namespace std;

//清空屏幕
void clear_screen()
{
#ifdef __linux__
system("clear");
#elif defined(_WIN32)
system("cls");
#endif
}

//获取随机数
long long random_number(int range)
{
srand(time(NULL));
int answer = rand() % range;
return answer;
}

//保存成绩
void save_score(long long answer, long long score)
{
cout << "请问是否需要记录您的成绩?(Y/n)" << endl;
char save = _getch();
if (save == 'Y' || save == 'y')
{
cout << "请输入您的姓名:";
string name;
cin >> name;
cout << endl;
cout << "开始进行成绩记录……" << endl;
ofstream out("./CaishuReload2_Data/Score.txt", ios::app);
out << "记录者:" << name << ",正确答案:" << answer << ",猜测次数:" << score << "" << endl;
out.close();
cout << "记录完成,感谢您的游玩,再见!" << endl;
}
else if (save == 'n' || save == 'N')
{
cout << "感谢您的游玩,再见!" << endl;
}
}

//游戏模式1
void game_mode_1()
{
long long range = 0;
cout << "请输入随机数的取值范围(最终的答案将会在0~x之间):";
cin >> range;
int answer = random_number(range);
clear_screen();
long long score = 0;
long long guess = 0;
while (true)
{
score++;
cout << "请进行您的第" << score << "次猜测:";
cin >> guess;
if (guess > answer)
{
cout << "大了" << endl << endl;
}
if (guess < answer)
{
cout << "小了" << endl << endl;
}
if (guess == answer)
{
break;
}
}
clear_screen();
cout << "太棒了,猜测正确!" << endl;
cout << "统计信息:" << endl;
cout << "正确答案是" << answer << ",您总共猜测了" << score << "次。" << endl;
save_score(answer, score);
}

//查询成绩
void read_score()
{
ifstream in("./CaishuReload2_Data/Score.txt");
string line;
if (in) //有该文件
{
while (getline(in, line)) //line中不包括每行的换行符
{
cout << line << endl;
}
}
else //没有该文件
{
cout << "成绩读取失败,也许还没有记录的成绩呢?" << endl;
}
}

//主菜单(无多平台支持:没有getch函数)
void main_menu()
{
cout << "+------------------------+" << endl;
cout << "|欢迎来到猜数 - 重制版2!|" << endl;
cout << "|请选择您的游戏模式: |" << endl;
cout << "|1.经典模式(可选择范围)|" << endl;
cout << "|2.查询记录的游戏成绩 |" << endl;
cout << "+------------------------+" << endl;
cout << "请输入想玩的游戏模式的序号:";
char mode = _getch();
clear_screen();
if (mode == '1')
{
game_mode_1();
}
else if (mode == '2')
{
read_score();
}
}

//主函数
int main()
{
#ifdef _WIN32
system("title 猜数 - 重制版2 // By CJYKK");
system("color 17");
#endif
main_menu();
system("pause");
}
100 changes: 100 additions & 0 deletions 猜数重制版/猜数重制版.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// ����(���壬�й�) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
#pragma code_page(936)

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END

3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END

#endif // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,0,1
PRODUCTVERSION 2,0,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080404b0"
BEGIN
VALUE "CompanyName", "Nope."
VALUE "FileDescription", "һ���򵥵IJ�����Ϸ"
VALUE "FileVersion", "0.0.0.1"
VALUE "InternalName", "�������ư�.exe"
VALUE "LegalCopyright", "Copyright (C) 2021 CJYKK Personal"
VALUE "OriginalFilename", "�������ư�.exe"
VALUE "ProductName", "���� - ���ư�2"
VALUE "ProductVersion", "2.0.0.0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x804, 1200
END
END

#endif // ����(���壬�й�) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

Loading

0 comments on commit aec8bb9

Please sign in to comment.