Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include <windows.h>
- #include<stdlib.h>
- #include<math.h>
- using namespace std;
- void Rand()
- {
- float NUM;
- ofstream myfile;
- for (int i = 0; i < 10; ++i)
- {
- NUM = (rand() % 210 - 100) / 10.0;
- myfile << NUM << " ";
- }
- myfile.close();
- }
- void NegN(float* mas)
- {
- ofstream neg;
- neg.open("NEG.txt");
- int temp = 0;
- for (int i = 0; i < 10; ++i)
- {
- if (mas[i] < 0)
- {
- cout << mas[i] << "\t ";
- ++temp;
- neg << mas[i] << "\t";
- }
- }
- cout << "\ntemp= " << temp << endl;
- neg << "\ntemp= " << temp;
- neg.close();
- }
- void PosN(float* mas)
- {
- ofstream pos;
- pos.open("POS.txt");
- int temp = 0;
- for (int i = 0; i < 10; ++i)
- {
- if (mas[i] > 0)
- {
- cout << mas[i] << "\t ";
- ++temp;
- pos << mas[i] << "\t";
- }
- }
- cout << "\ntemp1= " << temp;
- pos << "\ntemp1= " << temp;
- pos.close();
- }
- int main()
- {
- Rand();
- float mas[10];
- int i = 0;
- ifstream In;
- In.open("Stepin.txt");
- while (!(In.eof()))
- {
- In >> mas[i];
- ++i;
- }
- NegN(mas);
- PosN(mas);
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement