Advertisement
Soverein

Untitled

Mar 5th, 2021
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include <windows.h>
  4. #include<stdlib.h>
  5. #include<math.h>
  6. using namespace std;
  7. void Rand()
  8. {
  9. float NUM;
  10. ofstream myfile;
  11. for (int i = 0; i < 10; ++i)
  12. {
  13. NUM = (rand() % 210 - 100) / 10.0;
  14. myfile << NUM << " ";
  15. }
  16. myfile.close();
  17. }
  18. void NegN(float* mas)
  19. {
  20. ofstream neg;
  21. neg.open("NEG.txt");
  22. int temp = 0;
  23. for (int i = 0; i < 10; ++i)
  24. {
  25. if (mas[i] < 0)
  26. {
  27. cout << mas[i] << "\t ";
  28. ++temp;
  29. neg << mas[i] << "\t";
  30. }
  31. }
  32. cout << "\ntemp= " << temp << endl;
  33. neg << "\ntemp= " << temp;
  34. neg.close();
  35. }
  36. void PosN(float* mas)
  37. {
  38. ofstream pos;
  39. pos.open("POS.txt");
  40. int temp = 0;
  41. for (int i = 0; i < 10; ++i)
  42. {
  43. if (mas[i] > 0)
  44. {
  45. cout << mas[i] << "\t ";
  46. ++temp;
  47. pos << mas[i] << "\t";
  48. }
  49. }
  50. cout << "\ntemp1= " << temp;
  51. pos << "\ntemp1= " << temp;
  52. pos.close();
  53. }
  54. int main()
  55. {
  56. Rand();
  57. float mas[10];
  58. int i = 0;
  59. ifstream In;
  60. In.open("Stepin.txt");
  61. while (!(In.eof()))
  62. {
  63. In >> mas[i];
  64. ++i;
  65. }
  66. NegN(mas);
  67. PosN(mas);
  68. return 0 ;
  69. }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement