El código fuente del sistema de gestión del campus es gratuito.
#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 de amplificador
QueryTable( Estudiante,Número); );
Pausa;
Caso "A": Caso "A":
AppendToTable(Estudiante);
Caso; "I": Caso "I":
InsertToTable(Estudiante);
Caso 'S': Caso 'S':
SortTable(estudiante) );
puts(" ¡Ordenar compilado! Utilice el comando L para enumerar.
);
Pausa;
Caso "F":Caso "F":
Búsqueda (estudiante);
Pausa;
Caso "M": Caso "M":
Modi (estudiante);
Pausa; Caso "V": Caso "V":
Guardar(Estudiante);
Caso "O": Caso "O":
Cargar(Estudiante);
Caso; "H": Celda "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-gt;número =0;
Stu-gt;nombre[0]= '\0';
Stu-gt;tele[0]='\ 0 ';
Stu-gt; enlace = NULL
Retorno (stu);
}
void AppendToTable(struct s estudiante * stu)
{
struct SStudent * siguiente, * último
int número;
último = stu
mientras(último->; link)last = last-gt;link;
printf("Ingrese un número (0 significa salir):");
scanf( "d", número de amplificador);
mientras(número)
{
siguiente =(estructura s estudiante *)malloc(tamañode(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
Finalmente - gt; p>
último = último - gt; link;
printf("\nPor favor ingrese un número (0 significa salir): ");
scanf("d", número de amplificador);
}
Finalmente - gt; link = NULL
}
void InsertToTable(struct s Student * stu)
{
struct SStudent * next, * last
int number;
printf(" Ingrese un número (0 significa salir ): ");
scanf ("d ", número de amplificador);
while (número)
{ p>
next = (struct s Student *)malloc(sizeof(struct s Student));
Siguiente-
gt; número = número;
printf("Ingrese su nombre: ");
scanf("s", siguiente- gt; nombre); > printf("Por favor ingrese tele: ");
scanf("s ", next- gt; tele
last = stu
mientras( último ->; enlace)
{
if(último- gt; enlace-gt; número gt siguiente- gt; número)
{
Siguiente - gt; enlace = último - gt; enlace;
Último - gt; enlace = siguiente
Romper;
} p >
else last = last- gt; link;
}
printf("\nPor favor ingrese un número (0 significa salir): ");
scanf("d ", número de amplificador);
}
}
tabla de consulta nula (estructura s estudiante * stu, número sin firmar) p>
{
estructura SStudent *temp, *siguiente
siguiente = stu
mientras(siguiente->; enlace)
p>
{
if (siguiente-gt; enlace-gt; número == número)
{
temp = siguiente-gt ; enlace;
next-gt; enlace = next-gt; enlace-gt;
Gratis (temporal);
}
else next = next- gt; link
}
}
void print table(struct s Student * stu)
{
Stu=Stu- gt; link;
if (!Stu)
{
puts( "La tabla ¡está vacío!");
Return;
}
printf(" número \ tname \ ttele \ n ");
Cuando(Stu)
{
printf("3d\t ", stu- gt; número);
printf("-s \t ", stu- gt; nombre);
printf ("-s\t", stu- gt; tele
printf (" \ n "); p>Stu=Stu-gt; 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-gt; enlace-gt; número gt último-gt; enlace-gt; número)
{
temp = último-gt;
último-gt;
enlace = último-gt; enlace-gt; enlace
temp->; enlace = siguiente-gt; p>flag = 0;
Romper;
}
else next = next- gt; >
if(flag)last = last- gt; link;
}
}
Guardado no válido (estructura estudiante * estudiante) p >
{
Nombre de archivo de caracteres[13];
FILE * fileSave
printf("Ingrese el nombre del archivo que desea guardar:" );
scanf("s", nombre de archivo);
if((fileSave = fopen(nombre de archivo," WB))== 0)
{
printf("¡No se pueden abrir los archivos!\n ", nombre del archivo);
Regresar
}
puts( " Guardar...");
Stu=Stu-gt;Enlace;
Cuando(Stu)
{
fwrite( stu, sizeof(struct SStudent), 1, file save);
Stu=Student-gt; link;
}
puts("¡Guardado completado! ");
}
Carga no válida (estructura estudiante*estudiante)
{ char filename[13]; ltbr gtFILE * fileLoad ltbr gtstruct SStudent * temp ltbr gt while(stu->enlace) ltbr gt{ ltbr gttemp = stu-gt; ltbr gttu-gt; enlace = stu-gt; ltbr gtfree(temporal); p>temp =(struct s Student *)malloc(sizeof(struct s Student));
printf("Ingrese el nombre del archivo que desea cargar: ");
scanf("s ", nombre de archivo);
if((fileLoad = fopen(nombre de archivo, " Rb))== 0)
{
printf ("¡No se pueden abrir archivos! \n ", nombre del archivo);
Return;
}
puts("Cargando...");
mientras (fread(temp,sizeof(struct SStudent),1,fileLoad))
{Estudiante - gt; enlace = temp ltbr gtStudent = Stu - gt gttemp = (struct s estudiante *)malloc; (sizeof(struct s Student)); ltbr gt}
Stu- gt; link = NULL
puts("¡Carga completa!");
p >
}
Ayuda no válida()
{ puts(" * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * ");
puts(" *Ayuda de comandos del sistema* ");
puts (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ");
puts(" * L = Listar todos los registros * ");
puts(" * D = Eliminar registros seleccionados por número * "); = Agregar registro * ");
puts(" * I = Insertar registro * ");
puts(" * S = Ordenar registro * ");
puts(" * F=Buscar registro* ");
puts(" * M= Registro Modi* "); puts(" * H=Mostrar este mensaje de ayuda* ");
puts(" * V = Guardar registros en el archivo * ");
puts(" * O = Cargar registros desde el archivo * "); Q =Salir del sistema* ");
puts(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ");
}
void modi(estructura estudiante *h)
{
struct s Student * p; /*Mover puntero*/
Número sin firmar; /*Variable utilizada para almacenar el número de estudiante*/
//clrscr() ;/*Borrar el screen*/
System("cls");
printf("Ingrese el número que desea modificar\n ");
scanf ("d ", ampnum);/*Ingrese el número de estudiante*/
p = h;/*Asigne el puntero principal a p*/
while((p- gt; número! = num) amp; ampp! =NULL) /*Cuando el nombre del registro no es el nombre que buscas y el puntero no está vacío*/
p = p- gt; El puntero se mueve al siguiente nodo*/
If(p==NULL) /*Si el puntero es nulo*/
printf("\nLista número d estudiante\n" , número); /*No mostrar estudiantes*/
De lo contrario /*Modificar la información del registro encontrado*/
{
printf("Por favor, 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 "); -| -| \ n ");
printf(" | 6d | -10s | 12s | \ n ", p- gt; número, p- gt; nombre, p- gt; tele); }
}
Búsqueda no válida (struct Student *h)
{
struct s Student * p /*Mover puntero* /
char s[10];/*usado para almacenar nombres
Matriz de caracteres*/
//clrscr(); /*Borrar la pantalla*/
Sistema ("cls");
printf("Por favor, ingrese Nombre de búsqueda \ n ");
scanf("s ", s); /*Ingrese el nombre*/
p = h; /*Asigne el puntero principal a p* /
while(strcmp(p- gt; nombre y dirección. ampp!=NULL) /*Cuando el nombre grabado no es el nombre que estás buscando y el puntero no es nulo*/
p = p- gt; link; /*Mover el puntero al siguiente nodo*/
If(p==NULL) /*Si el puntero es nulo*/
printf ("\nlistar no s estudiante\n ", s); /*Mostrar no 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 ");
}
}