Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- void zadanie1()
- {
- vector<string> slownik;
- fstream file;
- file.open("slownik.txt", ios::in);
- if (!file.good())
- return;
- while (!file.eof())
- {
- string temp;
- getline(file, temp);
- if(temp[0] == 'z' || temp[0] == 'Z')
- slownik.push_back(temp);
- }
- for (int i = 0; i < slownik.size(); i++)
- cout << slownik[i] << endl;
- file.close();
- }
- void zadanie2()
- {
- vector<string> slownik;
- fstream file;
- file.open("slownik.txt", ios::in);
- if (!file.good())
- return;
- while (!file.eof())
- {
- string temp;
- getline(file, temp);
- int pos = temp.length() - 1;
- if ( pos>=0 && (temp[pos] == 'a' || temp[pos] == 'A'))
- slownik.push_back(temp);
- }
- fstream file2;
- file2.open("wynik2.txt", ios::out);
- if (!file2.good())
- return;
- for(int i = 0; i < slownik.size(); i++)
- file2 << slownik[i] << endl;
- file2.close();
- file.close();
- }
- void zadanie3()
- {
- fstream file;
- file.open("wynik3.txt", ios::out);
- if (!file.good())
- return;
- for (int i = 0; i < 1000; i++)
- file << (rand() % 6000) + 3000 << endl;
- file.close();
- }
- {void zadanie4()
- vector<string> slownik;
- fstream file;
- file.open("slownik.txt", ios::in);
- if (temp.lenght())
- return;
- while (!file.eof())
- {
- string temp;
- getline(file, temp);
- int pos = temp.length() - 1;
- if ( pos>=0 && (temp[pos] == 'a' || temp[pos] == 'A'))
- slownik.push_back(temp);
- }
- fstream file2;
- file2.open("wynik4.txt", ios::out);
- if (!file2.good())
- return;
- for(int i = 0; i < slownik.size(); i++)
- file2 << slownik[i] << endl;
- file2.close();
- file.close();
- }
- int main()
- {
- srand(time(NULL));
- zadanie1();
- zadanie3();
- zadanie2();
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement