/// IQ Test.cpp : main project file. #include "stdafx.h" #include #include #include #include #include #include struct people { people *left, *right; int kol;//порядковый номер тестирующегося char sorname[30];//фамилия char name[30];//имя char patronymic[30];//отчество char profession[30]; //профессия int age;//возраст float date ;//дата прохождения тестирования float iq;//IQ человека который проходил тестирование }; //struct answer//Структура содержащяя информащию об ответе //{ bool variant;//Вид вопроса 0-тестовый вариант 1 - вариант где нужно ввести слово. // int t;//содержит номер правильного ответа // char vord;//содержит слово которое нужно ввести // //}; struct test//структура содержащая информацию об тесте { int no;//номер вопроса char qwestion[400];//вопрос. int grade;//балы за данный вопрос. bool variant;//Вид вопроса 0-тестовый вариант 1 - вариант где нужно ввести слово. int t;//содержит номер правильного ответа char vord;//содержит слово которое нужно ввести }; void input(people **h, people **t)//Ввод инвормации о тестирующихся и запись ее в файл { FILE *f; f=fopen("People.txt","a+"); system("cls"); people *current = NULL; //выделяем память if (!(current = (people *)malloc(sizeof(people)))) return; //если очередь не существует if (!*t) { *h = current; (*h)->right = NULL; } else { (*t)->left = current; current->right = *t; } *t = current; (*t)->left = NULL; printf("Заполните пожалуста анкету"); printf("Ваша фамилия :"); scanf("%s",current->sorname); fprintf(f,"%s\n",current->sorname); printf("Ваше имя :"); scanf("%s",current->name); fprintf(f,"%s\n",current->name); printf("Ваше отчество :"); scanf("%s",current->patronymic); fprintf(f,"%s\n",current->patronymic); printf("Ваша профессия :"); scanf("%s",current->profession); fprintf(f,"%s\n",current->profession); printf("Ваш возраст:"); scanf("%d",¤t->age); fprintf(f,"%d\n",current->age); printf("Дата проходения тестирования"); scanf("%d",¤t->date); fprintf(f,"%d\n",current->date); system("cls"); printf("Спасибо за информацию"); fclose(f); } void output(people **h, people **t)//Вывод информации о тестируемых из файла {FILE *f; f = fopen("People.txt","r"); people *h = NULL; people *t = NULL; people *current = NULL; //выделяем память if (!(current = (people *)malloc(sizeof(people)))) return; //если очередь не существует if (!*t) { *h = current; (*h)->right = NULL; } else { (*t)->left = current; current->right = *t; } *t = current; (*t)->left = NULL; do { printf( "Тестируемый №"); fscanf(f,"%d",¤t->kol); if(feof(f))break; printf( "%d\n",current->kol); fscanf(f,"%s",¤t->sorname); printf( "Фамилия:\n"); printf( "%s\n",current->sorname); printf( "Имя:\n"); fscanf(f,"%s",¤t->name); printf( "%s\n",current->name); printf( "Отчество:\n"); fscanf(f,"%s",¤t->patronymic); printf( "%s\n",current->patronymic); printf( "Место работы:\n"); fscanf(f,"%s",¤t->profession); printf( "%s\n",current->profession); printf( "Ваш возраст:\n"); fscanf(f,"%d",¤t->age); printf( "%d\n",current->age); printf( "Дата проходения тестирования:\n"); fscanf(f,"%d",¤t->date); printf( "%d\n",current->date); printf( "IQ\n"); fscanf(f,"%d",¤t->iq); printf( "%d\n",current->iq); }while(!feof(f)); fclose(f); getch(); } void inputqwestions(test *an) { FILE *f; f=fopen("qwestions.txt","a+"); system("cls"); printf("Введите вопрос"); printf("Введите вид ответа(0-тестовый 1 -вариант где нужно ввести слово)"); if(an->variant =='0') { printf("Введите номер правильного ответа"); scanf("%d",an->variant); fprintf(f,"%d\n",an->variant); } else { printf("Введите слово отвечающее на вопрос"); scanf("%s",an->vord); fprintf(f,"%s\n",an->vord); } fclose(f); } void testing(people *hum,test *an) { } void statistics(people *hum) { } void edit(people *hum) { FILE *f; f = fopen("People.txt","r"); do { printf( "Тестируемый №"); fscanf(f,"%d",&hum->kol); if(feof(f))break; printf( "%d\n",hum->kol); fscanf(f,"%s",&hum->sorname); printf( "Фамилия:\n"); printf( "%s\n",hum->sorname); fscanf(f,"%s",&hum->name); fscanf(f,"%s",&hum->patronymic); fscanf(f,"%s",&hum->profession); fscanf(f,"%d",&hum->age); fscanf(f,"%d",&hum->date); fscanf(f,"%d",&hum->iq); hum=(people*)realloc(hum, sizeof(hum) + sizeof(people)); hum=hum+1; }while(!feof(f)); fclose(f); getch(); } void admin(people **h, people **t,*hum,test *an) { do{ printf("Добро пожаловать, насальника.Выберите что будем делать:\n"); printf("1-Просмотреть базу тестировавшихся:\n2-Редактировать вопросы:\n3-Добавить вопросы:\n0-Выход"); switch(getch()) { case'1':{system("cls");output(&h,&t);} case'2':{system("cls");edit(hum);} case'3':{system("cls");inputqwestions(an);} case'0':{system("cls");break;} }}while(getch()!='0'); } void main() {setlocale(LC_ALL,"rus"); people *h = NULL; people *t = NULL; test *an; an=(test*)calloc(1,sizeof(test)); people *hum; hum=(people*)calloc(1,sizeof(people)); do{ printf("Добро пожаловать,выберите операцию которую хотите произвести:\n"); printf("1-Пройти тестирование:\n2-Посмотреть статистику:\n3-Администрирование:\n0-Выход"); switch(getch()) { case'1':{system("cls");input(&h,&t);} case'2':{system("cls");statistics(hum);} case'3':{system("cls");printf("Введите пароль\n"); do{ if(getch()!='a'){printf("Пароль не верен\n");printf("Желаете выйти?(y/n)\n");} else admin(&h,&t,human);} while(getch()!='y');} case'0':{system("cls");break;} }}while(getch()!='0'); }