Sistema de gestión de información estudiantil c
----------------------------------------------- --- -----------------------------------------------
#include "stdio.h"
#include "stdio.h"/*Función de E/S*
#include "stdlib.h"/ *Otros comentarios**
#include "string.h"/*Funciones de cadena*
#include "conio.h"/*Funciones de manipulación de pantalla*
#include "mem.h" /*Función de operación de memoria**
#include "ctype.h"/* Función de operación de caracteres***
#include "alloc.h "/* Función de asignación dinámica de direcciones* **
Puntuación de estructura
{
int mingci;
char xuehao[8];
char mingzi[20];
puntuación flotante[6];
}datos, información[1000];
int i , j, k=0;
char temp[20], ch;
ARCHIVO * fp, *fp1
void shuru()
{ p>
if((fp=fopen("s_score.txt", "ab "))==NULL)
{
printf ("no se puede abrir este archivo.
");
getch(); i=0; ilt; = 1000; i )
{
printf("
Por favor, shuru xuehao: "); gets( data.score[1]=atof(temp);
printf("Ingrese la puntuación yingyu: ");
gets(temp); data.score[4] =atof(temp);
datos.puntuación[0] datos.puntuación[1] datos.puntuación[2] datos.puntuación[3] datos.puntuación[4];
fwrite(amp;datos, tamaño de(datos), 1, fp
printf("otro ?y/n");
ch=getch(); p>
if( ch==n||ch==N)
romper;
} fclose(fp);
} p>
info[ j].mingci=k;
printf("6s 8s 3.1f 3.1f 3.1f 3.1f 3.1f
", info[j]. xuehao, info[j]. mingzi, info[j].score[0], info[j].score[1], info[j].score[2], info[j].score[3], info. [j].puntuación[4 ],
<p> info[j].score[5]);
}
getch();
fclose(fp).
}
void xiugai()
{
if((fp=fopen("s_score.txt", "rb "))==NULL| |(fp1=fopen("temp.txt", "wb "))==NULL)
{
printf("No se puede abrir este archivo.
");
exit(0);
}
printf("
Por favor, shuru xiugai xuehao: ");
scanf("d ",amp;i); getchar();
while((fread(amp;data,sizeof(data),1,fp))==1 )
{
j=atoi(data.xuehao);
if(j==i)
{
printf("xuehao: s
mingzi: s
", datos.xuehao, datos.mingzi.mingzi);
printf(" Por favor, shuru mingzi: ");
gets(data. mingzi);
printf("Por favor, shuru yuwen puntuación: ");
gets(temp) ;data.score[0]=atof(temp);
printf("Por favor, shuru shuxue puntuación:" );
gets(temp); atof(temp);
printf("Ingrese la puntuación huaxue: ");
gets(data.score[4]=atof(temp); >
datos.puntuación[5]=datos.puntuación[0] datos.puntuación[1] datos.puntuación[2] datos.puntuación[3] datos.puntuación[4];
} fwrite(amp; datos, tamaño de(datos), 1, fp1
}
fseek(fp, 0L, 0);
fseek(fp1); , 0L, 0);
while((fread(amp;data,sizeof(data),1,fp1))==1)
{
fwrite(amp; datos, tamaño de(datos), 1, fp
}
fclose(fp);
fclose(fp1);
}
void chazhao()
{
if((fp=fopen("s_score.txt", "rb") )==NULL)
{
printf("
No se puede abrir este archivo.
" );
salir(0);
}
printf("
Por favor, shuru xuehao chakan:");
scanf("d", amp; i
while(fread(amp; datos, tamaño de(datos), 1, fp)==1)
{
j=atoi(data.xuehao);
if(i==j)
{
printf("xuehao: s mingzi: s
yuwen: f
shuxue: f
yingyu: f
wuli: f
huaxue: f
", data.xuehao, data.mingzi , datos.puntuación[0], datos.puntuación[0], datos.puntuación[0], datos.puntuación[0], datos.puntuación[0].puntuación[0], datos.puntuación[1], datos. puntuación[2], datos.puntuación[3], datos.puntuación[4], datos.puntuación[5]
}getch(); >
}
void shanchu()
{
if((fp= fopen("s_score.txt", "rb "))= =NULL||(fp1=fopen("temp.txt", "wb "))==NULL)
{
printf("
abrir puntuación.txt falló ");
getch();
salir(0);
}
printf("
Ingrese el ID que desea eliminar: ");
scanf("d", & i); getchar();
while((fread (amp; datos, tamaño de (datos), 1, fp))==1)
{
j=atoi(data.xuehao);
if(j==i)
{
printf("Cualquier tecla lo eliminará.
");
getch() ;
continuar;
}
fwrite(amp; datos, tamaño de(datos), 1, fp1
}<); /p>
fclose(fp);
fclose(fp1);
eliminar("s_score.txt"); .txt", "s_score.txt");
printf("¡La eliminación de datos fue exitosa!
");
printf("Cualquier tecla volverá a principal.");
getch();
}
principal()
{
mientras (1)
{
clrscr(); /* Borrar pantalla*/
gotoxy(1, 1); p>
color de texto (AMARILLO)
; /* Establece el color de visualización del texto en amarillo*/
textbackground(BLUE /* Establece el color de fondo en azul*/
window(1, 1, 99, 99); ) ) /* Crea una ventana que muestra el menú, cuyo tamaño depende del número de elementos del menú*/
clrscr();
printf("**** **** *****bienvenido a utilizar la gestión de estudiantes******************
");
printf(" ** ****************************menú********************* ********** ******
");
printf("* ============== ========== ==== =============================== *
");
printf("* 1gt; shuru 2gt; xiugai *
");
printf("* 3gt; shanchu 4gt; chazhao *
") ;
printf("* 5gt; xianshi 6gt; salir *
");
printf("* *
") ;
printf("* -------------------------- -- ------- ------------------ *
");
printf("Por favor, introduzca cuál querer(1-6) : ");
ch=getch();
cambiar(ch)
{
caso 1: shuru(); romper;
caso 2: xiugai();
caso 3: shanchu(); > caso 4: chazhao( );
caso 5.xianshi();
caso 6: salida(0); continuar
}
}
}
}