master
Kirigaya Kazuto 2018-06-17 12:12:32 +08:00
parent 65683bcf7f
commit b8b7b710d0
3 changed files with 51 additions and 0 deletions

Binary file not shown.

40
ui_helper.cpp Normal file
View File

@ -0,0 +1,40 @@
#include "ui_helper.h"
#include <Windows.h>
#include <cstdlib>
#include <cstdio>
void ClearScreen()
{
system("cls");
}
void ClearInput()
{
int c;
while ((c = getchar()) != '\n' && c != EOF);
}
void WaitPause()
{
system("pause");
}
void title(const std::string& xtitle)
{
ClearScreen();
printf("==============================\n");
printf("%s\n", xtitle.c_str());
printf("==============================\n");
}
int GetChoice(int max_id)
{
int x;
while (scanf("%d", &x) != 1 || x<1 || x>max_id)
{
printf("输入有误. 应为在1~%d范围内的数字. 请重试.\n", max_id);
ClearInput();
}
ClearInput();
return x;
}

11
ui_helper.h Normal file
View File

@ -0,0 +1,11 @@
#pragma once
#include <string>
void ClearScreen();
void ClearInput();
void WaitPause();
void title(const std::string& xtitle);
int GetChoice(int max_id);