Advertisement
qradmanq

dz 4.1

Oct 8th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. int main()
  5. {
  6. ifstream fin("C:\\testing\\test.txt");
  7. if (fin.is_open())
  8. {
  9. int *mass = new int[10];
  10. int i = 0;
  11. while (fin >> mass[i])
  12. {
  13. i++;
  14. }
  15. int m = i;
  16. int sum = 0;
  17. for (int j = 0; j < m; j++)
  18. {
  19. cout << mass[j] << " ";
  20. sum += mass[j];
  21. }
  22. cout << endl;
  23. cout << sum << endl;
  24. fin.close();
  25. delete[] mass;
  26. }
  27. else
  28. cout << "File ne naiden." << endl;
  29. system("pause");
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement