Cómo programar un sistema de gestión de empleados usando punteros en lenguaje C
#include "stdio.h"
#define TYPE structworker
#define LEN sizeof (structworker)
struct trabajador // La estructura del trabajador, puede agregar el nombre del trabajador nuevamente si es necesario.
{
int id;
int gongzi; //salario
char xueli[20]; //educación
struct trabajador *next;
};
struct trabajador *head;
TYPE *creat(int n) //crear lista de trabajadores
{
trabajador de estructura *head, *pf, *pb;
int i;
for(i=0; ilt ;n;i )
{
pb=(TYPE*) malloc(LEN);
printf("ingrese la identificación, el salario y la educación de los trabajadores: \n");
scanf("dd",amp;pb-gt;id,amp;pb-gt;gongzi);
scanf("s",amp; pb-gt;xueli);
if (i==0)
pf=head=pb
else pf-gt;
pb-gt; siguiente=NULL;
pf=pb;
}
retorno(cabeza);
}
void display() //imprimir información del trabajador
{
struct trabajador *temp;
if(head == NULL)
{
printf("La lista es NULL"
return;
temp=cabeza;
hacer
{
printf("d d s\n", temp-gt; id, temp-gt; gongzi, temp-gt;xueli);
temp=temp-gt;next;
} while(temp!=NULL);
}
void delete(int id)
{
int serched = 0; //¿Puedo encontrar datos si la tabla de cadena no está vacía?
struct trabajador *temp, *temp1;
if(head == NULL)
{
printf("La lista es NULL");
devolver
}
temp= temp1=cabeza
hacer
{
if(id == temp-gt;id)
{
if(temp==head)
head = head -gt;siguiente; p> p>
else
temp1-gt; siguiente = temp-gt; siguiente
serched=1;
/p>
temp1=temp;
temp = temp-gt
} while(temp!=NULL);<
si; (!serched)
printf("ID correspondiente\n no encontrado");
}
int main()
{
int idinfo;
head=creat(3); //creando 10
display(); //mostrar
printf ("intercambie la identificación del redactor para eliminar:");
scanf("d", idinfo
eliminar(idinfo
display ()); ;// mostrar
}