Red de conocimiento informático - Conocimiento informático - Código fuente del sistema de gestión de estudiantes

Código fuente del sistema de gestión de estudiantes

#Incluir "stdio.h"

#Incluir "stdlib.h"

#Incluir "conio.h"

#Incluir "string.h"

Estructura estudiante

{

Número sin firmar;

Nombre del personaje[10];

char tele[ 12 ];

struct SStudent * link

};

void main()

{

struct s estudiante * crear tabla();

void AppendToTable(struct s estudiante * stu);

void InsertToTable(struct s estudiante * stu);

nular consulta table(struct s Student * stu, número sin firmar);

void sort table(struct s Student * stu);

void print table(struct s Student * stu); p>

void Save(struct s estudiante * stu);

Void load(struct s estudiante * stu

void Help();

< p); >void modi(struct s Student * h);

void search(struct s Student * h; struct SStudent *student;

Número sin firmar;

valor de clave char;

estudiante = crear tabla();

//clrscr();

Sistema ("cls");

help();

printf(" \ n = ");

while((keyValue = getche())!= ' q ' & amp& amp valor clave ! = ' Q ' & valor clave amp& amp = 27)

{

puts(" ");

Cambiar (valor clave)

{

Caso "L": Caso "L":

PrintTable(estudiante);

Caso "D": Caso "D" :

printf("Ingrese el número que desea eliminar:");

scanf("%d ", & número);

QueryTable( estudiante,número);

Pausa;

Caso "A":Caso "A":

AppendToTable(estudiante Pausa;

Caso "I":Caso "I":

InsertToTable(Estudiante Descanso;

Caso 'S':Caso 'S':

SortTable(estudiante);

puts(" ¡Clasificación compilada! Utilice el comando L para enumerar.

);

Pausa;

Caso "F":Caso "F":

Búsqueda (estudiante);

Pausa;

Caso "M": Caso "M":

Modi (estudiante);

Descanso; Caso "V": Caso "V":

Guardar(Estudiante); Descanso;

Caso "O": Caso "O":

Cargar(Estudiante Descanso);

Caso "H":Case "H":

ayuda(); break;

Valor predeterminado: puts("¡Comando incorrecto!");

}

printf(" \ n = ");

}

}

struct SStudent * CreateTable()

{

struct SStudent * stu

stu =(struct s Student *)malloc(sizeof(struct s Student));

Stu->número =0;

Stu->nombre[0]='\0'

Stu->tele[0] = '\0';

Stu->link = NULL

Return (stu);

}

void AppendToTable(struct s Student * stu)

{

estructura SStudent * siguiente, * último

int número;

último = stu

mientras(último->enlace) last = last->link;

printf("Ingrese un número (0 significa salir):");

scanf("%d ", & amp número);

mientras(número)

{

siguiente = (estructura s estudiante *)malloc (tamaño de(estructura s estudiante));

Siguiente-& gt;número=número;

printf("Ingrese su nombre:");

scanf("%s ", siguiente-& gt; nombre);

printf("Ingrese tele:");

scanf("%s ", siguiente-& gt ;tele);

Último-> link = next

last = last->Link;

printf("\nIngrese un número (0 significa salir):

scanf ("%d ", & número);

}

Finalmente -> enlace = NULL

}

void InsertToTable( struct s estudiante * stu)

{

struct SStudent * siguiente, * último

int número;

printf("Por favor ingrese un número (0 significa salir):");

scanf("%d ", & amp número);

p>

mientras(número)

{

siguiente =(struct s estudiante *)malloc(sizeof(struct s estudiante));

Siguiente a->número=número;

printf ("Por favor, introduzca su nombre:");

scanf("%s ", next->nombre);

p>

printf("Por favor

Ingrese tele: ");

scanf("%s ", siguiente-& gt;tele);

último = stu

mientras(último-> ; enlace)

{

if(último->enlace->número>next->número)

{

Siguiente ->enlace = último->enlace;

Último->enlace = siguiente

Pausa;

}

else last = last-& gt; link;

}

printf("\nPor favor ingrese un número (0 significa salir):" );

scanf( "%d ", & amp número);

}

}

tabla de consulta nula (estructura s estudiante * stu, número sin firmar)

{

estructura SStudent * temp, * siguiente

siguiente = stu

mientras(siguiente a->enlace)

{

if (siguiente->enlace->número == número)

{

temp = siguiente->enlace;

siguiente->enlace = siguiente->enlace->enlace;

Gratis (temporal);

}

si no, siguiente = siguiente-& gt; enlace;

}

}

tabla de impresión nula (estructura s estudiante * stu)

{

Stu=Stu->Link;

If (!Stu)

{

puts("¡La mesa está vacía!");

Regresar;

}

printf ("número \ tname \ ttele \ n ");

Cuando(Stu)

{

printf("%3d\t ", stu- >número);

printf("%-s\t ",stu->nombre) ;

printf("%-s\t ",stu- >tele);

printf("\n");

Stu=Stu ->Enlace;

}

}

void SortTable(estructura estudiante * estudiante)

{

struct SStudent * siguiente, * último, * temp

int flag;

último = stu

mientras(último->; enlace)

{

siguiente = stuflag = 1 ;

mientras(siguiente->;Enlace! = último->enlace)

{

if(siguiente->enlace->número>last->enlace->número)

{

temp = último->enlace;

último->enlace = último->enlace->enlace

temp->enlace = siguiente; ->link;

siguiente->link=temp

flag = 0;

Romper;

}

más siguiente = ne

xt-& gt;Enlace;

}

if(flag)last = último-& gt;Enlace;

}

}

Guardado no válido (estructura estudiante*estudiante)

{

Nombre de archivo de carácter [13];

ARCHIVO * archivoGuardar p>

printf("Ingrese el nombre del archivo que desea guardar:");

scanf("%s ", nombre del archivo);

if( (fileSave = fopen(nombre de archivo, " WB)) = = 0)

{

printf("¡No se puede abrir el archivo %s!\n ", nombre de archivo);

Regresar;

}

puts("Guardar...");

Stu=Stu-& gt;Enlace;

Cuando(Estudiante)

{

fwrite(stu, sizeof(struct SStudent), 1, guardar archivo);

Stu=Estudiante Figura ->Enlace;

}

puts("¡Guardado completado!");

}

Carga no válida (estructura estudiante * estudiante)

{ nombre de archivo char[13]; & ltbr & gtFILE * fileLoad& ltbr & gtstruct SStudent * temp& ltbr & gt while(stu->; enlace)& ltbr & gt{ & ltbr & gttemp = stu- >link;<br>Stu->link = stu->link->link;<br>Free(temporary);<br>}

temp =(struct s Student *)malloc(sizeof(struct s Student) );

printf("Ingrese el nombre del archivo que desea cargar:");

scanf("%s ", nombre del archivo);

if((fileLoad = fopen(nombre de archivo, " Rb))= = 0)

{

printf("¡No se puede abrir el archivo %s!\n ", nombre de archivo);

Return;

}

puts("Cargando..." );

while(fread(temp, sizeof(struct SStudent), 1, fileLoad))

{Estudiante->link=temp<br>Student=Estudiante Figura->Link;<br>temp=(struct s Student *)malloc(sizeof(struct s Student));<br> }

Stu->link=NULL

puts("¡Carga completada! ");

}

Ayuda no válida()

{ puts(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ");

puts(" *Ayuda de comandos del sistema* ");

puts(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ");

puts(" * L = listar todos los registros * ");

>

puts(" * D = Eliminar registro seleccionado por número * ");

puts(" * A = Agregar registro * "); = Insertar registro * ");

puts(" * S = Ordenar registro * ");

puts(" * F = Buscar registro * ");

puts(" * M= Registro Modi * "); puts(" * H = Mostrar este mensaje de ayuda * "

puts(" * V = Guardar registro en archivo * ");

puts(" * O = Cargar registros desde el archivo * ");

puts(" * Q = Salir del sistema * "); * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ");

}

void modi(struct Student *h)

{

struct s Student * p /* mover puntero */

Número sin firmar; /*Variable utilizada para almacenar el número de estudiante*/

//clrscr() /*Borrar pantalla*/

Sistema ("cls") ;

printf("Ingrese el número a modificar \ n ");

scanf("%d ", & ampnum /*Ingrese el número de estudiante*/

p = h; /*Asignar el puntero principal a p*/

while((p-& gt; number!= num)&&p!=NULL) /*Cuando Cuando el nombre del registro no es el nombre que buscas y el puntero no es nulo*/

p = p->Link;/*Mover el puntero al siguiente nodo*/

Si (p==NULL) /*Si el puntero es nulo*/

printf(" \nNúmero de lista %d estudiante\ n ", número /*No mostrar estudiantes*/

<); p>De lo contrario/*Modificar la información del registro encontrado*/

{

printf("Ingrese un nuevo nombre:");

scanf(" % s ", p-& gt; nombre);

printf("Ingrese un nuevo número de teléfono: ");

scanf("%s ", p-& gt ; tele);

printf(" | número | nombre | tel | \ n ");

printf(" |-|-|-| \ n ");

p>

printf(" | % 6d | %-10s | % 12s | \ n ",p->número,p->nombre,p->tele);}

}

Búsqueda no válida (struct Student *h)

{

struct s Student * p /* mover puntero */

char s[10];/*Matriz de caracteres utilizada para almacenar nombres*/

//clrscr();/*Borrar la pantalla*/

System("cls ") ;

printf("Ingrese el nombre de búsqueda\ n ");

scanf("%s ", s /*Ingrese el nombre*/

< p); >p = h;/*Asigna el puntero principal a p*/

while(strcmp(p-& gt;Nombre y dirección.

& amplificador! =NULL) /*Cuando el nombre del registro no es el nombre que buscas y el puntero no es nulo*/

p = p->Link;/*Mover el puntero al siguiente nodo*/

If(p==NULL) /*Si el puntero es nulo*/

printf("\nlist no %s estudiante\n ", s); *No mostrar estudiantes */

Else /*Mostrar la información del registro encontrado*/

{

printf(" \ n \ n * * * * * * * * * * * * * * * * * * * * *Encontrado* * * * * * * * * * * * * * * * * * * * * * * * \n ");

printf(" | número | nombre | tel | \ n ");

printf(" |-|-|-| \ n ");

printf(" | % 10d | %-10s | % 12s | \ n ", p-& gt; número, p-& gt; nombre, p-& gt; tele);

printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * * fin * * * * * * * * * * * * * * * * * * * * * * * * * * \n " );

}

}