%s %s %s %d - %d\n",people->surname,people->name,people->farther,people->faculty,people->group,people->form,people->year,people->mark); }
while(pv != NULL) {
if (pv->mark == value)
{
printf("--- %s %s %s %s %s %s %d - %d\n",pv->surname,pv->name,pv->farther,pv->faculty,pv->group,pv->form,pv->year,pv->mark); }
pv = pv->next; }
printf("-------------------------------------------------------------\n"); }
break;
case 's':
for (value = 5;value > 2; --value)
{
pv = people->next;
if (people->mark == value) {
printf("--- %s %s %s %s %s %d - %d\n",people->surname,people->name,people->farther,people->group,people->form,people->year,people->mark); }
while(pv != NULL) {
if (pv->mark == value) {
printf("--- %s %s %s %s %s %d - %d\n",pv->surname,pv->name,pv->farther,pv->group,pv->form,pv->year,pv->mark); } pv = pv->next;
}
printf("\n-------------------------------------------------------------\n"); }
break;
default:
printf("You enter not right simbol!!!");
break; }
delete people;
delete pv;
getch();}
void deleting(void){
clrscr();
student *begin;
begin = new student;
begin->surname = new char [20];
begin->form = new char [6];
begin->group = new char [7];
begin->name = new char [10];
begin->farther = new char [20];
begin->faculty = new char [20];
student *pv;
pv = new student;
pv->surname = new char [20];
pv->form = new char [6];
pv->group = new char [7];
pv->name = new char [10];
pv->farther = new char [20];
pv->faculty = new char [20];
begin = form();
printf("%i - %s %s %s %s %s %s %d %d\n",begin->ind,begin->surname,begin->name,begin->farther,begin->faculty,begin->group,begin->form,begin->year,begin->mark);
pv = begin->next;
while(pv != NULL) {
printf("%i - %s %s %s %s %s %s %d %d\n",pv->ind,pv->surname,pv->name,pv->farther,pv->faculty,pv->group,pv->form,pv->year,pv->mark);
pv = pv->next; }
printf("\nWhat element needs to be deleted?\n");
int del;
pv = begin->next;
scanf("%d",&del);
if (begin->ind == del)
{
begin->for_delete = 1;
printf("deleted"); }
else {
while((pv->ind != del)&&(pv->next != NULL)) pv = pv->next;
if (pv->ind == del) {
pv->for_delete = 1;
printf("deleted"); }
else {
printf("This element not found"); } }
getch();
FILE *handle;
if ((handle = fopen("stud.dat","w+")) == NULL) {
printf("Error of opening file with data\n");
getch();
exit(1); }
int pos = 1;
while(begin != NULL) {
fprintf(handle,"%d %s %s %s %s %s %s %d %d %d\n",pos,begin->surname,begin->name,begin->farther,
begin->faculty,begin->group,begin->form,begin->year,begin->mark,begin->for_delete);
begin = begin->next;
++pos; }
delete begin;
delete pv;
fclose(handle);}
void revival(void){
student *sPtr;
sPtr = new student;
sPtr->for_delete = 0;
sPtr->surname = new char [20];
sPtr->form = new char [6];
sPtr->group = new char [7];
sPtr->name = new char [10];
sPtr->farther = new char [20];
sPtr->faculty = new char [20];
student *pos;
pos = new student;
pos->for_delete = 0;
pos->surname = new char [20];
pos->form = new char [6];
pos->group = new char [7];
pos->name = new char [10];
pos->farther = new char [20];
pos->faculty = new char [20];
FILE *handle;
clrscr();
if ((handle = fopen("stud.dat","r")) == NULL) {
printf("Error of opening file with data\n");
getch();
exit(1); }
fscanf(handle,"%i %s %s %s %s %s %s %d %d %d\n",&sPtr->ind,sPtr->surname,sPtr->name,sPtr->farther,
sPtr->faculty,sPtr->group,sPtr->form,&sPtr->year,&sPtr->mark,&sPtr->for_delete);
pos = sPtr;
do {
student *pv;
pv = new student;
pv->for_delete = 0;
pv->surname = new char [20];
pv->form = new char [6];
pv->group = new char [7];
pv->name = new char [10];
pv->farther = new char [20];
pv->faculty = new char [20];
fscanf(handle,"%i %s %s %s %s %s %s %d %d %d\n",&pv->ind,pv->surname,pv->name,pv->farther,
pv->faculty,pv->group,pv->form,&pv->year,&pv->mark,&pv->for_delete);
pos->next = pv;
pos = pv;
}while(!feof(handle));
fclose(handle);
if ((handle = fopen("stud.dat","w+")) == NULL) {
printf("Error of opening file with data\n");
getch();
exit(1);
}
fseek(handle,0,0);
int index = 1;
while(sPtr != NULL) {
fprintf(handle, "%i %s %s %s %s %s %s %d %d %d\n", index,sPtr->surname,sPtr->name,sPtr->farther,
sPtr->faculty,sPtr->group,sPtr->form,sPtr->year,sPtr->mark,0);
sPtr = sPtr->next;
++index; }
fclose(handle);}
void main (void){
int index = 0;
index = get_index();
char ch = '0';
do {
clrscr();
printf("Select your choise:\n1:completing\n2:deleting\n3:forming of list\n4:revival");
ch = getch();
switch(ch) {
case '1':
complete(index);
++index;
break;
case '2':
deleting();
break;
case '3':
forming();
break;
case '4':
revival();
break;
default:
if (ch == 0x1b) exit(0);
else {
clrscr();
printf("You enter error!!!\nPlease reenter your choice");
getch();
break; } }
}while(1);}
//KYRS.H
//COMPLETE GET_INDEX LDELETE FORM
struct student{
int ind;
char *surname;
char *name;
char *farther;
char *faculty;
int year;
char *group;
char *form;
int mark;
student *next;
int for_delete;};
//-----------------------------------------------------------------
student* Ldelete(student *sPtr,int number){
student *pv;
pv = new student;
pv->for_delete = 0;
pv->surname = new char [20];
pv->form = new char [6];
pv->group = new char [7];
pv->name = new char [10];
pv->farther = new char [20];
pv->faculty = new char [20];
pv = sPtr->next;
student *people;
people = new student;
people->for_delete = 0;
people->surname = new char [20];
people->form = new char [6];
people->group = new char [7];
people->name = new char [10];
people->farther = new char [20];
people->faculty = new char [20];
people = sPtr->next->next;
if (sPtr->ind == number) sPtr = pv;
else {
while((people->ind != number)&&(pv->ind != number)) {
if (people == NULL) {
printf("Output to scopes!!! The data don't absent");
getch();
break; }
people = people->next;
pv = pv->next; }
if (pv->ind == number) sPtr->next = people;
else
if (people->ind == number) {
people = people->next;
pv->next = people; } }
return sPtr;}
//-----------------------------------------------------------------------
student* form (void){
FILE *handle;
if ((handle = fopen("stud.dat","r")) == NULL) {
printf("Error of opening file with data\n");
getch();
exit(1); }
student *sPtr;
sPtr = new student;
sPtr->for_delete = 0;
sPtr->surname = new char [20];
sPtr->form = new char [6];
sPtr->group = new char [7];
sPtr->name = new char [10];
sPtr->farther = new char [20];
sPtr->faculty = new char [20];
student *pos;
pos = new student;
pos->for_delete = 0;
pos->surname = new char [20];
pos->form = new char [6];
pos->group = new char [7];
pos->name = new char