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;
- int main()
- {
- SetConsoleOutputCP(1251);
- SetConsoleCP(1251);
- float mas[10];
- float temp, temp1;
- ofstream myfile;
- myfile.open("Stepin.txt");
- if (!(myfile.is_open()))
- {
- cout << "file not found\n";
- cout << "exit";
- cin.get(); //Это если окошко сразу закрывается, задерживаем
- return -1;
- }
- else
- {
- float NUM;
- for (int i = 0; i < 10; ++i)
- {
- NUM = (rand() % 210 - 100) / 10.0;
- mas[i] = NUM;
- cout << mas[i]<<"\t ";
- myfile << mas[i]<<" ";
- }
- cout << "\n";
- }
- ofstream neg;
- neg.open("NEG.txt");
- if (!(neg.is_open()))
- {
- cout << "File not found";
- cout << "exit";
- cin.get(); //Это если окошко сразу закрывается, задерживаем
- return -1;
- }
- else
- {
- 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;
- }
- ofstream pos;
- pos.open("POS.txt");
- if (!(pos.is_open()))
- {
- cout << "File not found";
- cout << "exit";
- cin.get(); //Это если окошко сразу закрывается, задерживаем
- return -1;
- }
- else
- {
- temp1 = 0;
- for (int i = 0; i < 10; ++i)
- {
- if (mas[i] > 0)
- {
- cout << mas[i] << "\t ";
- ++temp1;
- pos << mas[i] << "\t";
- }
- }
- cout << "\ntemp1= " << temp1;
- pos << "\ntemp1= " << temp1;
- }
- myfile.close();
- pos.close();
- neg.close();
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement