Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <fstream>
- #include <iostream>
- using namespace std;
- /*
- *
- */
- bool rw(char *f_io, int *oi_mas, bool flag);
- void i_f(int *mas, int *o_mas, int el);
- int main() {
- char f_in[15] = "input.txt";
- char f_out[15] = "output.txt";
- int *mas = new int[90];
- int *o_mas = new int[90];
- if(rw(f_in,mas,1)){
- cout << "Enter a value Element:" << endl;
- int element;
- cin >> element;
- i_f(mas,o_mas,element);
- rw(f_out,o_mas,0);
- }
- return 0;
- }
- void i_f(int *mas, int *o_mas, int el){
- int n=0;
- int i=0;
- while(mas[i]!='\0'){
- if(el>mas[i]){
- o_mas[n]=mas[i];
- n++;
- }
- i++;
- }
- }
- bool rw(char *f_io, int *oi_mas, bool flag){
- int n=0;
- if(flag){
- ifstream fin(f_io);
- if(fin){
- while(!fin.eof()){
- fin >> oi_mas[n];
- n++;
- }
- fin.close();
- return 1;
- }else cout << "ERROR: DON'T OPEN " << f_io << "!"<< endl; return 0;
- }else{
- ofstream fout(f_io);
- if(fout){
- int i=0;
- while(oi_mas[i]!='\0'){
- fout << oi_mas[i] << " ";
- i++;
- }
- return 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement