#include<iostream.h> #include<conio.h> #include<stdio.h> struct sinhvien { char MaSV[10]; char TenSV[30]; float t,l,tb; }; void nhap(sinhvien sv[],int n) { int i; for(i=0;i<n;i++) { cout<<"nhap sinh vien thu:"<<i+1<<endl; cout<<"nhap ma sv:"; gets(sv[i].MaSV); cout<<"nhap ten sv:"; gets(sv[i].TenSV); cout<<"nhap diem toan:"; cin>>sv[i].t; cout<<"nhap diem ly:"; cin>>sv[i].l; sv[i].tb=(sv[i].t + sv[i].l)/2; } } void xuat(sinhvien sv[],int n) { int i; for(i=0;i<n;i++) {
cout<<sv[i].MaSV<<"\t"<<sv[i].TenSV<<"\t"<<sv[i].t<<"\t"<<"\t"<<sv[i].l<<"\t"<<"\t"<<sv[i].tb<<"\t"<<endl; } } void main() { sinhvien sv[10]; int n; cout<<"nhap so sinh vien :"; cin>>n; nhap(sv,n); cout<<"sinh vien sau khi nhap :\n"; cout<<"Ma sinh vien"<<"\t"<<"Ten sv"<<"\t"<<"\tDiem toan"<<"\t"<<"Diem ly"<<"\t"<<"\tdiem tb"<<"\t"<<endl; xuat(sv,n); getche(); }