mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 20:08:42 +00:00
96d4a3ecf7
Due to historical reasons, the code is in subfolder "1". With SVN removal, we place the code back and remove the annoying "1" folder.
56 lines
1.1 KiB
C++
56 lines
1.1 KiB
C++
#include <cstdio>
|
|
|
|
inline const char *englishEnding(int x)
|
|
{
|
|
x %= 100;
|
|
if (x / 10 == 1)
|
|
return "th";
|
|
if (x % 10 == 1)
|
|
return "st";
|
|
if (x % 10 == 2)
|
|
return "nd";
|
|
if (x % 10 == 3)
|
|
return "rd";
|
|
return "th";
|
|
}
|
|
|
|
int main(int argc, char * argv[])
|
|
{
|
|
if (argc != 4)
|
|
return 1;
|
|
FILE *fout = fopen(argv[2], "r");
|
|
FILE *fans = fopen(argv[3], "r");
|
|
|
|
if (fout == NULL || fans == NULL)
|
|
return 1;
|
|
|
|
int n = 0;
|
|
while (true)
|
|
{
|
|
n++;
|
|
int c, d;
|
|
c = fgetc(fout);
|
|
d = fgetc(fans);
|
|
if (c == EOF && d == EOF)
|
|
break;
|
|
if (c != d)
|
|
{
|
|
if (c == EOF)
|
|
fprintf(stderr, "wrong answer %d%s byte differ - expected EOF found '%c'\n", n, englishEnding(n), (char)d);
|
|
else if (d == EOF)
|
|
fprintf(stderr, "wrong answer %d%s byte differ - expected '%c' found EOF\n", n, englishEnding(n), (char)c);
|
|
else
|
|
fprintf(stderr, "wrong answer %d%s byte differ - expected '%c' found '%c'\n", n, englishEnding(n), (char)c, (char)d);
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
if (n == 0)
|
|
fprintf(stderr, "ok empty file\n");
|
|
else if (n == 1)
|
|
fprintf(stderr, "ok single byte\n");
|
|
else
|
|
fprintf(stderr, "ok %d byte\n", n);
|
|
return 0;
|
|
}
|