40 lines
674 B
C++
40 lines
674 B
C++
#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;
|
|
} |