Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <cstring>
  3. #include <ctime>
  4. #include <fstream>
  5. using namespace std;
  6. struct magazin
  7. {
  8. char ime[50];
  9. int brstoki;
  10. double oborot;
  11. };
  12. magazin mas[100];
  13. int n;
  14. void filll()
  15. {
  16. cin>>n;
  17. for(int i=0;i<n;i++)
  18. {cin.ignore();
  19. cin.getline(mas[i].ime,50);
  20. cin>>mas[i].brstoki;
  21. cin>>mas[i].oborot;}
  22.  
  23. }
  24. void writefile(char *pathfile)
  25. {
  26. ofstream f(pathfile,ios::in);
  27. for(int i=0;i<n;i++)
  28. {f<<mas[i].ime<<endl;
  29. f<<mas[i].brstoki<<endl;
  30. f<<mas[i].oborot<<endl;}
  31. f.close();
  32. }
  33. void show()
  34. {
  35. for(int i=0;i<n;i++)
  36. cout<<mas[i].ime<<' '<<mas[i].brstoki<<' '<<mas[i].oborot<<' ';
  37. }
  38. void indmax(char *pathfile1)
  39. {
  40. ofstream f1(pathfile1,ios::app);
  41. double m=mas[0].oborot;
  42. for(int i=0;i<n;i++)
  43. if(m<mas[i].oborot)
  44. m=mas[i].oborot;
  45. f1<<m<<endl;;
  46. f1.close();
  47.  
  48. }
  49. void averge(char *pathfile1)
  50. {
  51. double br=0.0;
  52. double q;
  53. ofstream f1(pathfile1,ios::app);
  54. for(int i=0;i<n;i++)
  55. br=br+mas[i].oborot;
  56. q=br/double(n);
  57. f1<<q;
  58. f1.close();
  59.  
  60. }
  61. void readfile(char *pathfile2)
  62. {
  63. ifstream f2(pathfile2,ios::in);
  64.  
  65. }
  66. int main()
  67. {
  68. char pathfile[200]="D:\\Jelqzkova\\Georgi 9a\\readf.txt";
  69. char pathfile1[200]="D:\\Jelqzkova\\Georgi 9a\\readf1.txt";
  70. char pathfile2[200]="D:\\Jelqzkova\\Georgi 9a\\readf2.txt";
  71. filll();
  72. writefile(pathfile);
  73. show();
  74. indmax(pathfile1);
  75. averge(pathfile1);
  76.  
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement