-
Notifications
You must be signed in to change notification settings - Fork 0
/
spj_template.cpp
62 lines (54 loc) · 1.42 KB
/
spj_template.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <bits/stdc++.h>
#define AC 0
#define WA 1
#define ERROR -1
int spj(FILE *input, FILE *user_output);
void close_file(FILE *f) {
if (f != NULL) {
fclose(f);
}
}
int main(int argc, const char *args[]) {
FILE *input = NULL, *user_output = NULL;
int result;
if (argc != 3) {
printf("Usage: spj x.in x.out\n");
return ERROR;
}
input = fopen(args[1], "r");
user_output = fopen(args[2], "r");
if (input == NULL || user_output == NULL) {
printf("Failed to open output file\n");
close_file(input);
close_file(user_output);
return ERROR;
}
result = spj(input, user_output);
printf("result: %d\n", result);
close_file(input);
close_file(user_output);
return result;
}
using namespace std;
int spj(FILE *input, FILE *user_output) {
/*
parameter:
- input,The FILE pointer of input file
- user_output,The FILE pointer of user's output
return:
- If the answer is correct, return AC
- If the answer is wrong, return WA
- If you actively capture your own errors,
such as memory allocation failure, return ERROR
Please complete the function on your own.
demo:
int a, b;
while(fscanf(user_output, "%d %d", &a, &b) != EOF){
if(a - b != 3){
return WA;
}
}
return AC;
*/
return AC;
}