[C++] bài toán quản lí sinh viên

Nếu bài này hay hãy chia sẽ ngay.

Link Music :
Link Forum :
* Ca Khúc : [C++] bài toán quản lí sinh viên
#include <stdio.h>
#include <ctype.h>
#include <mem.h>
#include <string.h>

#define max 100
#define toan 0
#define ly 1
#define hoa 2

struct sinhvien {
char mslop[5];
char hoten[35];
float diem[3];
} danhsach[max];
int n = 0;

void nhapmoi()
{
char mslop[5], tmp[3];
int i;
float diem[3];
do {
printf("\ncho biet ma so lop : ");
gets(mslop);
if (strlen(mslop))
{
strcpy(danhsach[n].mslop, mslop);
printf("\ncho biet ho ten : ");
gets(danhsach[n].hoten);
printf("\ncho biet diem so : ");
for (i=0; i<3; i++)
{
scanf("%f", &diem[i]);
danhsach[n].diem[i] = diem[i];
}
gets(tmp);
n++;
}
} while (strlen(mslop));
}

void timkiem()
{
char mslop[5];
int i = 0, found = 0;
printf("\ncho biet ma so lop : ");
gets(mslop);
if (strlen(mslop))
while (i<n)
if (stricmp(danhsach[i].mslop, mslop) == 0)
{
printf("\nma so lop : %s", danhsach[i].mslop);
printf("\nho va ten : %s", danhsach[i].hoten);
printf("\ndiem toan : %f", danhsach[i].diem[toan]);
printf("\ndiem ly : %f", danhsach[i].diem[ly]);
printf("\ndiem hoa : %f", danhsach[i].diem[hoa]);
found = 1;
break;
}
else
i++;
if (!found)
printf("\nkhong tim thay!!!");
}

void xoa()
{
char mslop[5], traloi;
int i = 0, j;
printf("\ncho biet ma so lop : ");
gets(mslop);
if (strlen(mslop))
while (i<n)
if (stricmp(danhsach[i].mslop, mslop) == 0)
{
printf("\nma so lop : %s", danhsach[i].mslop);
printf("\nho va ten : %s", danhsach[i].hoten);
printf("\ndiem toan : %f", danhsach[i].diem[toan]);
printf("\ndiem ly : %f", danhsach[i].diem[ly]);
printf("\ndiem hoa : %f", danhsach[i].diem[hoa]);
printf("\nco muon xoa khong (c/k)? ");
do {
traloi = toupper(getch());
} while (traloi != 'c' && traloi != 'k');
putc(traloi, stdout);
if (traloi == 'c')
{
n--;
memcpy(&danhsach[i], &danhsach[i+1], sizeof(struct sinhvien) * (n-i));
break;
}
}
else
i++;
}

void menu()
{
printf("\n***************");
printf("\n* 1. Them *");
printf("\n* 2. Xoa *");
printf("\n* 3. Tim kiem *");
printf("\n* 0. Thoat *");
printf("\n***************");
printf("\nchon lua ? ");
}

void main()
{
char traloi;
do {
menu();
do {
traloi = getch();
} while (traloi < '0' || traloi > '3');
putc(traloi, stdout);
switch (traloi)
{
case '1' : nhapmoi();
break;
case '2' : xoa();
break;
case '3' : timkiem();
break;
}
} while (traloi != '0');
}
** Thể Loại :

Coppy link gửi cho bạn bè

List of songs with Thể Loại

0 nhận xét : [C++] bài toán quản lí sinh viên

Đăng nhận xét

[▼/▲] Emoticons

 
  • Copyright (C) 2013 Nonstop.All rights reserved. Powered by Blogger - Best view with 1024x768
  • Admin: Kay Media --- Website : KayPhim.Com
  • Liên hệ trực tuyến : kay_media | Email: kayphim@gmail.Com
  • Web thành lập ngày 20-4-2013 | Edit by Kay_Media