>>599
scanf("%d", &num);
fflush(stdin);
↓
fgets(rf, LINE_BUF, stdin);
sscanf(rf, "%d", &num);