📄 utils_1.cpp
字号:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <iostream.h>
#include <fstream.h>
#include <ctype.h>
#include <wchar.h>
#include "Utils_1.h"
////////////////////////////////////////////////////////////////////////////
//
// Cout
//
////////////////////////////////////////////////////////////////////////////
reportbuf ReportBuf;
ostream ReportOut(&ReportBuf);
////////////////////////////////////////////////////////////////////////////
//
// General purpose functions
//
////////////////////////////////////////////////////////////////////////////
inline BOOLEAN is_double_digit(int c)
{
return (isdigit(c) || (c == '.') || (c == '-') || (c == '+') || (c == 'e'));
}
ifstream &operator>>(ifstream &file, double &d)
{
static char buffer[100];
int i = 0;
while (!is_double_digit(file.peek()))
file.get();
do
file >> buffer[i++];
while(is_double_digit(file.peek()));
buffer[i] = '\0';
d = atof(buffer);
return file;
}
ifstream &operator>>(ifstream &file, int &num)
{
static char buffer[100];
int i = 0;
while (!is_double_digit(file.peek()) || (file.peek() == 'e'))
file.get();
do
file >> buffer[i++];
while(is_double_digit(file.peek()));
buffer[i] = '\0';
num = atoi(buffer);
return file;
}
int uniform_random(int p_max)
// Returns an integer between 0 and p_max - 1
{
return (int)floor(my_rand() * (double)p_max);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -