SAS/MenuUtils.cpp

29 lines
538 B
C++
Raw Normal View History

2022-07-04 00:31:52 +08:00
#include"MenuUtils.h"
void checkOptInput(int& opt, int low, int high) {
printf(">>><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>(%d-%d)<29><>", low, high);
while (!(cin >> opt) || (opt < low) || (opt > high)) {
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
cin.clear();
while (cin.get() != '\n');
}
}
string doubleToString(double num) {
char* buf;
int dec, sign;
buf = _fcvt(num, 2, &dec, &sign);
string str;
if (sign) str += "-";
int i;
for (i = 0; i < dec; i++) {
str += buf[i];
}
str += ".";
for (; i < strlen(buf); i++) {
str += buf[i];
}
return str;
}