I will omit the whole code but these tests so far can be quite disturbing:
This get Accepted with ANSI C, C++ and C++ 11
#include <stdio.h>
#include <stdlib.h>
int main()
{
int p, q, r, s, t, u;
char* str = malloc(1000);
while(gets(str) != NULL) {
sscanf(str, "%d %d %d %d %d %d", &p, &q, &r, &s, &t, &u);
printf("%d %d %d %d %d %d\n", p, q, r, s, t, u);
}
}
The disturbing fact comes now, this code get Runtime Error in ANSI C but Accepted in C++ and C++ 11:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int p, q, r, s, t, u;
//== 6 instead of != EOF also gives me a runtime error
while(scanf("%d %d %d %d %d %d", &p, &q, &r, &s, &t, &u) != EOF) {
printf("%d %d %d %d %d %d\n", p, q, r, s, t, u);
}
}