Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <iostream>
  3. #include <fstream>
  4. using namespace std;
  5.  
  6.  
  7. void fill_in(int* a, int N, ifstream& file)
  8. {
  9. for (int i = 0; i < N; i++)
  10. {
  11. file >> a[i];
  12. cout << a[i] << " | ";
  13. }
  14. }
  15.  
  16. void simm(int *a, int N)
  17. {
  18. cout << endl << "Новый массив: ";
  19. for (int i = 0; i < N; i++)
  20. {
  21. if (i < N / 2)
  22. {
  23. int temp;
  24. temp = a[i];
  25. a[i] = a[N - i - 1];
  26. a[N - i - 1] = temp;
  27. }
  28. cout << a[i] << " | ";
  29. }
  30. }
  31.  
  32. int main()
  33. {
  34. setlocale(0, "Rus");
  35. ifstream file("J:\\Универ\\Программирование\\Практика_txt\\z_4.txt");
  36. if (file.is_open())
  37. {
  38. const int N = 100;
  39. int L[N];
  40. cout << "Массив L: ";
  41. fill_in(L, N, file);
  42. simm(L, N);
  43. system("pause");
  44. return 0;
  45. }
  46. else
  47. {
  48. cout << "Файл не открыт";
  49. system("pause");
  50. return 0;
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement