Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <string>
- #include <algorithm>
- #include <cmath>
- #include <map>
- #include <list>
- using namespace std;
- int a,b;
- bool ListCompare(int c){
- return ((c>a)&(c<b));
- }
- typedef unsigned uint;
- typedef unsigned long ulong;
- typedef unsigned long long ull;
- int main() {
- setlocale(LC_CTYPE,"rus");
- FILE *f1, *f2;
- map<string, int> book;
- //1
- vector<int> my_vec(5);
- ofstream fout;
- fout.open("D:\\f1.txt");
- for(uint i = 0; i < my_vec.size(); i++) {
- fout << i << endl;
- }
- fout.close();
- ifstream fin;
- fin.open("D:\\f1.txt");
- for(uint i = 0; i < my_vec.size(); i++) {
- fin >> my_vec[i];
- }
- fin.close();
- cout << " 1 - По возрастанию_" <<endl;
- cout << " 2 - По убыванию_"<<endl;
- int mod;
- cin >> mod;
- switch (mod) {
- case 1: sort(my_vec.begin(),my_vec.end() );
- case 2: {
- sort(my_vec.begin(), my_vec.end());
- reverse(my_vec.begin(), my_vec.end());
- }
- }
- fout.open("D:\\f1.txt");
- for(uint i = 0; i < my_vec.size(); i++) {
- fout << my_vec[i] <<' ';
- }
- fout <<endl;
- my_vec.clear();
- fout.close();
- //2
- FILE *f4;
- list <int> my_list;
- int n,j;
- string s1;
- ifstream fin_list;
- fin_list.open("D:\\f4.txt");
- cout << "Назовите файл_" << endl;
- cin >> s1;
- ofstream fout_list(s1);
- for (int j=0;j<5;j++){
- cin>>n;
- my_list.push_back(n);
- }
- fin_list.close("D:\\f4.txt");
- cout << "Введите 2 числа_" << endl;
- cin >> a >> b;
- my_list.remove_if(ListCompare);
- fout_list.open()
- for (list<int>::iterator I = my_list.begin(); I != my_list.end();I++){
- fout_list << *I <<endl;
- }
- }
- fout_list.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement