
Добавил:
Yanus
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
#include <stdio.h>
#include <conio.h>
#include <graphics.h>
main()
{
FILE *fp, *res;
char buf[4096];
char intro[4096];
char name[1024];
char *filename, *testname;
char c;
int n, scores[10], i, summ, min, max;
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("\n\nGraphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:\n\n");
getch();
exit(1);
}
settextstyle(1,0, 4);
setcolor(15);
outtextxy(120, 0, "Omskiy Gosudarstvennyy Tehnicheskiy Universitet");
outtextxy(120, 15, "Kafedra \"Informatika i vychislitelnaya tehnika\"");
outtextxy(200, 150, "Kursovoi proekt na yazike C");
outtextxy(200, 180, "Tema:Psihologicheskie testi");
outtextxy(400, 350, "Vypolnil: Malahov A.A. IVT-118");
outtextxy(400, 370, "Proverila: Shafeeva O.P.");
outtextxy(270, 450, "Omsk - 2009");
getch();
closegraph();
clrscr();
printf("Enter your name: ");
scanf("%s", &name);
while(1)
{
clrscr();
printf("Hello, %s!\n", name);
printf("Test: \n");
printf("1. Test1\n");
printf("2. Test2\n");
printf("3. Test3\n\n");
printf("4. Results\n\n");
printf("0. EXIT\n\n");
printf("\n\nTest?: ");
while ( ((c = getch() ) < 48) || (c > 52));
if (c == '0') exit(1);
switch(c)
{
case '1': filename = "test1.txt";
testname = "Test 1";
break;
case '2': filename = "test2.txt";
testname = "Test 2";
break;
case '3': filename = "test3.txt";
testname = "Test 3";
break;
case '4':
fp = fopen("result.txt", "rb");
while(fgets(buf, 4096, fp) != NULL)
{
printf("Name: %s", buf);
fgets(buf, 4096, fp);
printf("Test: %s", buf);
fgets(buf, 4096, fp);
printf("Result: %s\n", buf);
fgets(buf, 4096, fp);
}
getch();
break;
}
if (c != '4')
{
clrscr();
summ = 0;
fp = fopen(filename, "rb");
fgets(intro, 4096, fp);
while((fgets(buf, 4096, fp) != NULL) && (strcmp(buf, "RESULT\r\n") != 0))
{
clrscr();
printf("%s\n\n", intro);
printf("%s\n", buf);
fgets(buf, 4096, fp);
n = atoi(buf);
for(i = 0; i < n; i++)
{
fgets(buf, 4096, fp);
printf("%d) %s", i+1, buf);
fgets(buf, 4096, fp);
scores[i] = atoi(buf);
}
printf("\nOTBET: ");
c = 255;
while( ( (c-48) > n ) || ( c < 49 ))
c = getch();
summ += scores[c-49];
}
while(fgets(buf, 4096, fp) != NULL)
{
min = atoi(buf);
fgets(buf, 4096, fp);
max = atoi(buf);
fgets(buf, 4096, fp);
if ((summ >= min) && (summ <= max))
{
clrscr();
printf("\n\n%s", buf);
printf("\n\nPress any key to exit...");
res = fopen("result.txt", "a");
fputs(name, res);
fputs("\n", res);
fputs(testname, res);
fputs("\n", res);
fputs(buf, res);
fclose(res);
getch();
break;
}
}
fclose(fp);
} }
}
Соседние файлы в папке ToF