30/09/2018, 22:15
BT lập trình quản lý sinh viên bị lỗi
Mấy bạn coi thử mình xài chỗ nào mà lỗi cứ hiện hoài:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
struct student
{
char holot[50];
char ten[10];
int mssv;
int diem;
};
void nhap( student sv[20],int n);
void xuat( student sv[20],int n);
int main(int argc, char *argv[])
{
int n;
struct student sv[20];
printf("Nhap so luong sinh vien: ");
scanf("%d", &n);
return 0;
}
/*ho ten , ma sinh vien va diem cua sinh vien */
void nhap(student sv[20],int n)
{
for(int i=0;i<n;i++)
{
printf("
nhap vao ho lot :");
gets(sv[i].hoten);
printf("
nhap vao lop :");
gets(sv[i].lop);
printf("
nhap vao mssv:");
scanf("%d",&sv[i].mssv);
printf("
nap vao diem trung binh");
scanf("%d",&sv.diem);
}
}
void xuat (student sv[20],int n)
{
for(int i=0;i<n;i++)
{
printf("
ho ten :%c", sv[i].hoten);
printf("
lop :%c", sv[i].lop);
printf("
mssv:%c",sv[i].mssv);
printf("
diem trung binh %d",&sv.diem);
}
}
Bài liên quan
Lần sau bạn chú ý đặt tiêu đề đúng, rõ ràng, Tiếng Việt có dấu nhé và markdown code trong bài viết nhé.
Không là mình sẽ tạm thời unlist topic của bạn (tức là ko ai thấy được topic trừ bạn) cho tới khi bạn chỉnh sửa đầy đủ!
Hướng dẫn markdown:
student
sẽ không biết dc là kiểu dữ liệu gì. Thay bằngstruct student
vậy muốn tìm họ tên thông qua mssv thì làm hàm gì?
Viết thêm một phương thức tìm kiếm trong đó đầu vào là MSSV, kết quả trả về là họ tên.