更新 6.0s1.h
This commit is contained in:
parent
7ff05a5c4d
commit
b9a0f5d158
34
6.0s1.h
34
6.0s1.h
|
@ -6,10 +6,10 @@ struct s1_location {
|
||||||
int line;
|
int line;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int S1_INT;
|
typedef int s1_int;
|
||||||
typedef long long S1_LONG;
|
typedef long long s1_long;
|
||||||
typedef double S1_DOUBLE;
|
typedef double s1_double;
|
||||||
typedef char S1_CHAR;
|
typedef char s1_char;
|
||||||
|
|
||||||
|
|
||||||
#define S1_LOC() (struct s1_location){__FILE__, __LINE__}
|
#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
|
// 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);
|
int rc = printf("%d", value);
|
||||||
s1_assert(rc != EOF, "Error: write_int", loc);
|
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);
|
int rc = printf("%lld", value);
|
||||||
s1_assert(rc != EOF, "Error: write_long", loc);
|
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);
|
int rc = printf("%lf", value);
|
||||||
s1_assert(rc != EOF, "Error: write_long", loc);
|
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);
|
int rc = printf("%c", value);
|
||||||
s1_assert(rc != EOF, "Error: write_char", loc);
|
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_double(value) write_double(value, S1_LOC())
|
||||||
#define write_char(value) write_char(value, S1_LOC())
|
#define write_char(value) write_char(value, S1_LOC())
|
||||||
|
|
||||||
S1_INT read_int(struct s1_location loc) {
|
s1_int read_int(struct s1_location loc) {
|
||||||
S1_INT value = 0;
|
s1_int value = 0;
|
||||||
int rc = scanf("%d", &value);
|
int rc = scanf("%d", &value);
|
||||||
s1_assert(rc == 1, "Error: read_int", loc);
|
s1_assert(rc == 1, "Error: read_int", loc);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
S1_LONG read_long(struct s1_location loc) {
|
s1_long read_long(struct s1_location loc) {
|
||||||
S1_LONG value = 0;
|
s1_long value = 0;
|
||||||
int rc = scanf("%lld", &value);
|
int rc = scanf("%lld", &value);
|
||||||
s1_assert(rc == 1, "Error: read_long", loc);
|
s1_assert(rc == 1, "Error: read_long", loc);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
S1_DOUBLE read_double(struct s1_location loc) {
|
s1_double read_double(struct s1_location loc) {
|
||||||
S1_DOUBLE value = 0.0;
|
s1_double value = 0.0;
|
||||||
int rc = scanf("%lf", &value);
|
int rc = scanf("%lf", &value);
|
||||||
s1_assert(rc == 1, "Error: read_double", loc);
|
s1_assert(rc == 1, "Error: read_double", loc);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
S1_CHAR read_char(struct s1_location loc) {
|
s1_char read_char(struct s1_location loc) {
|
||||||
S1_CHAR value = 0;
|
s1_char value = 0;
|
||||||
int rc = scanf("%c", &value);
|
int rc = scanf("%c", &value);
|
||||||
s1_assert(rc == 1, "Error: read_char", loc);
|
s1_assert(rc == 1, "Error: read_char", loc);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_pnl(struct s1_location loc) {
|
void read_pnl(struct s1_location loc) {
|
||||||
S1_CHAR value = 0;
|
s1_char value = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
int rc = scanf("%c", &value);
|
int rc = scanf("%c", &value);
|
||||||
if (feof(stdin)) {
|
if (feof(stdin)) {
|
||||||
|
|
Loading…
Reference in New Issue