fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. struct SV
  4. {
  5. string ten;
  6. float toan,van;
  7. void nhap()
  8. {
  9. cin>>ten>>toan>>van;
  10. }
  11. float diemtrungbinh()
  12. {
  13. return (toan+van)/2;
  14. }
  15. void xuat()
  16. {
  17. cout<<"Ho va ten: "<<ten<<endl;
  18. cout<<"Diem toan: "<<toan<<endl;
  19. cout<<"Diem van: "<<van<<endl;
  20. cout<<"Diem trung binh: "<<diemtrungbinh()<<endl;
  21. }
  22. };
  23. int main()
  24. {
  25. SV sv;
  26. sv.nhap();
  27. sv.xuat();
  28. }
  29.  
Success #stdin #stdout 0.01s 5504KB
stdin
sang 7 8
stdout
Ho va ten: sang
Diem toan: 7
Diem van: 8
Diem trung binh: 7.5