Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <ctime>
  4. #include <cstdlib>
  5. #include <math.h>
  6. #include <sstream>
  7.  
  8. using namespace std;
  9.  
  10. void podpunkt_a(int n)
  11. {
  12. ofstream fout("wynik1.txt");
  13. string im, naz, m, tel;
  14. int wie;
  15.  
  16.  
  17. for(int i=0;i<n;i++)
  18. {
  19. cout<<"Dane "<<i<<" studenta"<<endl;
  20. cout<<"Imie: ";
  21. cin>>im;
  22. cout<<"Nazwisko: ";
  23. cin>>naz;
  24. cout<<"Wiek: ";
  25. cin>>wie;
  26. cout<<"Miejsce urodzenia: ";
  27. cin>>m;
  28. cout<<"Telefon: ";
  29. cin>>tel;
  30.  
  31. fout<<im<<" "<<naz<<"\t"<<wie<<"\t"<<m<<"\t"<<tel<<endl;
  32.  
  33.  
  34. }
  35.  
  36. fout.close();
  37. }
  38.  
  39. void podpunkt_b(int n)
  40. {
  41. ifstream fin("wynik1.txt");
  42. ofstream fout("podpunkt_b.txt");
  43. string im, naz, wie, m, tel;
  44.  
  45. for(int i=0;i<n;i++)
  46.  
  47. {
  48.  
  49. fin>>im>>naz>>wie>>m>>tel;
  50. fout<<im<<" "<<naz<<"\t"<<wie<<"\t"<<m<<"\t"<<tel<<endl;
  51. }
  52.  
  53.  
  54.  
  55. fout.close();
  56. fin.close();
  57. }
  58.  
  59. void podpunkt_c(int n)
  60. {
  61. ifstream fin("wynik1.txt");
  62. ofstream fout("podpunkt_c.txt");
  63. string im, naz, wie, m, tel;
  64.  
  65. for(int i=0;i<n;i++)
  66.  
  67. {
  68.  
  69. fin>>im>>naz>>wie>>m>>tel;
  70. fout<<naz<<"\t"<<tel<<endl;
  71. }
  72.  
  73.  
  74.  
  75. fout.close();
  76. fin.close();
  77.  
  78. }
  79.  
  80. void podpunkt_d(int n)
  81. {
  82. ifstream fin("wynik1.txt");
  83. ofstream fout("podpunkt_d.txt");
  84. string im;
  85. string naz;
  86. int wie;
  87. string m;
  88. string tel;
  89. int wiek;
  90.  
  91. for(int i=0;i<n;i++)
  92. {
  93.  
  94. wiek+=wie;
  95. cout<<wiek<<endl;
  96.  
  97. }
  98. cout<<wiek/n<<endl;
  99.  
  100.  
  101.  
  102.  
  103. }
  104.  
  105.  
  106. int main()
  107. {
  108. int n;
  109. cout<<"Podaj liczbe studentow: ";
  110. cin>>n;
  111.  
  112.  
  113. //podpunkt_a(n);
  114. podpunkt_b(n);
  115. podpunkt_c(n);
  116. podpunkt_d(n);
  117.  
  118.  
  119. return 0;
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement