int main() { /* test basic workings of stdarg macros */ Cstruct x = {3}; assert(tryit("iisdi", '\1', 2, x, 4.0, 5) == 5); assert(tryit("") == 0); assert(tryit("pdp", "\1", 2.0, "\3") == 3); printf("sizeof (va_list) = %u\n", sizeof (va_list)); puts("SUCCESS testing <stdarg.h>"); return (0); }
int main () { CONSOLE_SCREEN_BUFFER_INFO cinfo; DWORD tmp; if (fgets (str, sizeof (str), stdin)==NULL) return 0; int t=strlen (str); if (t&&str[t-1]=='\n') str[t-1]=0, --t; color=7; oklen=0; tryit ("Облом", 12); tryit ("Формат в/в", 13); tryit ("Неверный ответ", 9); tryit ("ok", 10); if (strlen (str)<oklen+4) oklen=0; if (!oklen) {_label:fprintf (stderr, "%s\n", str);} else { oklen+=4; HANDLE chandle=GetStdHandle (STD_ERROR_HANDLE); if (GetConsoleScreenBufferInfo (chandle, &cinfo)==FALSE) goto _label; fprintf (stderr, "%.*s", oklen, str); FillConsoleOutputAttribute (chandle, color, oklen, cinfo.dwCursorPosition, &tmp); t=strlen (str); if (t>=cinfo.dwSize.X) { fprintf (stderr, "%.*s", cinfo.dwSize.X-oklen, str+oklen); GetConsoleScreenBufferInfo (chandle, &cinfo); FillConsoleOutputAttribute (chandle, 7, cinfo.dwSize.X, cinfo.dwCursorPosition, &tmp); fprintf (stderr, "%s\n", str+cinfo.dwSize.X); } else fprintf (stderr, "%s\n", str+oklen); GetConsoleScreenBufferInfo (chandle, &cinfo); FillConsoleOutputAttribute (chandle, 7, cinfo.dwSize.X, cinfo.dwCursorPosition, &tmp); }; while (!feof (stdin)) { if (fgets (str, sizeof (str), stdin)==NULL) return 0; int t=strlen (str); if (t&&str[t-1]=='\n') str[t-1]=0, --t; fprintf (stderr, "%s\n", str); }; return 0; };
void calcAverage(Puzzle *puzzle, int count) { int i, t = 0; for (i = 0; i < count; i++) { tryit(puzzle, makePuzzle, 0, 0); t += puzzle->count; } printf("average %d\n", (t + 5 * i / 10) / i); }
int main(void) { Puzzle puzzleData; srand((unsigned)time(NULL)); tryit(&puzzleData, inputPuzzle, 0, 1); /* calcAverage(&puzzleData, 1000); */ return 0; }