Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5. struct vairuotojas
  6. {
  7. string pav, nr;
  8. int tsk;
  9. };
  10. void skaityti(vairuotojas V[], int &n, string &nr1);
  11. void rasyti(vairuotojas V[], int n, string nr1);
  12. int main()
  13. {
  14. vairuotojas V[100];
  15. int n;
  16. string nr1;
  17. skaityti(V,n, nr1);
  18. rasyti(V,n,nr1);
  19. return 0;
  20. }
  21.  
  22. void skaityti(vairuotojas V[], int &n, string &nr1)
  23. {
  24. ifstream in("duomenys.txt");
  25. in>>nr1;
  26. in>>n;
  27. char a[16];
  28. for(int i=0; i<n; i++)
  29. {
  30. in.ignore(80, '/n');
  31. in.get(a,16);
  32. V[i].pav=a;
  33. in.get(a,7);
  34. V[i].nr=a;
  35. in>>V[i].tsk;
  36. }
  37. in.close();
  38. }
  39. void rasyti(vairuotojas V[], int n, string nr1)
  40. {
  41. ofstream out("rezultatai.txt");
  42. out<<nr1<<endl;
  43. out<<n<<endl;
  44. for(int i=0; i<n; i++)
  45. {
  46. out<<V[i].pav<<" "<<V[i].nr<<" "<<V[i].tsk<<endl;
  47. }
  48. out.close();
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement