更新 6.0s1.h

This commit is contained in:
rabix 2024-06-07 09:33:04 +08:00
parent 7ff05a5c4d
commit b9a0f5d158
1 changed files with 17 additions and 17 deletions

34
6.0s1.h
View File

@ -6,10 +6,10 @@ struct s1_location {
int line;
};
typedef int S1_INT;
typedef long long S1_LONG;
typedef double S1_DOUBLE;
typedef char S1_CHAR;
typedef int s1_int;
typedef long long s1_long;
typedef double s1_double;
typedef char s1_char;
#define S1_LOC() (struct s1_location){__FILE__, __LINE__}
@ -36,22 +36,22 @@ void s1_trace(const char *text, struct s1_location loc) {
// 2. simple IO
void write_int(S1_INT value, struct s1_location loc) {
void write_int(s1_int value, struct s1_location loc) {
int rc = printf("%d", value);
s1_assert(rc != EOF, "Error: write_int", loc);
}
void write_long(S1_LONG value, struct s1_location loc) {
void write_long(s1_long value, struct s1_location loc) {
int rc = printf("%lld", value);
s1_assert(rc != EOF, "Error: write_long", loc);
}
void write_double(S1_DOUBLE value, struct s1_location loc) {
void write_double(s1_double value, struct s1_location loc) {
int rc = printf("%lf", value);
s1_assert(rc != EOF, "Error: write_long", loc);
}
void write_char(S1_CHAR value, struct s1_location loc) {
void write_char(s1_char value, struct s1_location loc) {
int rc = printf("%c", value);
s1_assert(rc != EOF, "Error: write_char", loc);
}
@ -61,36 +61,36 @@ void write_char(S1_CHAR value, struct s1_location loc) {
#define write_double(value) write_double(value, S1_LOC())
#define write_char(value) write_char(value, S1_LOC())
S1_INT read_int(struct s1_location loc) {
S1_INT value = 0;
s1_int read_int(struct s1_location loc) {
s1_int value = 0;
int rc = scanf("%d", &value);
s1_assert(rc == 1, "Error: read_int", loc);
return value;
}
S1_LONG read_long(struct s1_location loc) {
S1_LONG value = 0;
s1_long read_long(struct s1_location loc) {
s1_long value = 0;
int rc = scanf("%lld", &value);
s1_assert(rc == 1, "Error: read_long", loc);
return value;
}
S1_DOUBLE read_double(struct s1_location loc) {
S1_DOUBLE value = 0.0;
s1_double read_double(struct s1_location loc) {
s1_double value = 0.0;
int rc = scanf("%lf", &value);
s1_assert(rc == 1, "Error: read_double", loc);
return value;
}
S1_CHAR read_char(struct s1_location loc) {
S1_CHAR value = 0;
s1_char read_char(struct s1_location loc) {
s1_char value = 0;
int rc = scanf("%c", &value);
s1_assert(rc == 1, "Error: read_char", loc);
return value;
}
void read_pnl(struct s1_location loc) {
S1_CHAR value = 0;
s1_char value = 0;
while (1) {
int rc = scanf("%c", &value);
if (feof(stdin)) {