fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. struct NhanVien{
  4. string mnv,hvt;
  5. float hsl,lcb,pc;
  6. };
  7. NhanVien nv;
  8. void NhapNv() {
  9. ofstream os("nhanvien.txt");
  10. for(int i = 1; i <= 2; i++) {
  11. getline(cin, nv.mnv);
  12. getline(cin, nv.hvt);
  13. cin >> nv.hsl >> nv.lcb >> nv.pc;
  14. cin.ignore();
  15. os << nv.mnv << "\n" << nv.hvt << "\n" << nv.hsl << "\n" << nv.lcb << "\n" << nv.pc << "\n";
  16. }
  17. os.close();
  18. }
  19. void DocNv() {
  20. ifstream in("nhanvien.txt");
  21. while(getline(in, nv.mnv)) {
  22. getline(in, nv.hvt);
  23. in >> nv.hsl >> nv.lcb >> nv.pc;
  24. cout << nv.mnv << " " << nv.hvt << " " << nv.hsl * nv.lcb + nv.pc << endl;
  25. in.ignore();
  26. }
  27. }
  28. int main() {
  29. NhapNv();
  30. DocNv();
  31.  
  32. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty