Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <string>
- #include <cmath>
- #include <stack>
- #include <vector>
- #include <fstream>
- using namespace std;
- int main()
- {
- string name,nm,n;
- string znach;
- char s;
- vector<string> q;
- vector<string> lastname;
- bool ln = NULL;
- vector<string> res;
- fstream fout;
- cout << "Vvedite nazvanie faila" << endl;
- cin >> name;
- fout.open(name, ios::in);
- if (fout.is_open())
- {
- while (fout){
- fout >> s;
- if (s == '='|| s =='?'|| s == '&'){
- q.push_back(nm);
- nm.clear();
- nm.push_back(s);
- q.push_back(nm);
- nm.clear();
- }
- else nm.push_back(s);
- }
- }
- fout.close();
- ofstream out;
- out.open("/Users/redsquirrel/Desktop/output.txt",ios::app);
- for (int i = 0 ; i < q.size() ; ++i){
- if (q[i] == "=")
- n = q[i-1];
- for (auto g : lastname)
- if (n == g){
- ln = 1;
- break;
- }
- if (!ln){
- for (int j = 0 ; j < q.size()-2 ; ++j){
- if (q[j] == n)
- res.push_back(q[j+2]);
- }
- if (!res.empty()){
- out << n << "=[";
- for(int k = 0 ; k < res.size() ; ++k){
- if (k==0 && k==res.size()-1){
- out << res[k] << ']';
- break;
- }
- if (k==0)
- out << res[k] <<", ";
- else{
- if (k == res.size()-1)
- out << res[k] << ']' << ' ';
- else out << res[k];
- }
- }
- }
- res.clear();
- }
- ln = 0;
- lastname.push_back(n);
- }
- out.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement