Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define NM 1700
- using namespace std;
- ifstream fin ("dir.in");
- ofstream fout ("dir.out");
- typedef char fisier[260];
- void initializare(fisier x)
- {
- for(int i=0; x[i]; i++)
- x[i] = 0;
- }
- fisier s[105], aux;
- char c[NM];
- int n, k;
- multiset<string> rez;
- int main()
- {
- fin.getline(c, NM);
- n = strlen(c);
- for(int i=0; i<n; i++)
- {
- if(isupper(c[i]))
- {
- ++k;
- int j;
- for(j = i;isupper(c[j]) or isdigit(c[j]); j++)
- strncat(s[k], c+j, 1);
- i = j-1;
- }
- else if(islower(c[i]))
- {
- initializare(aux);
- ++k;
- int j = i;
- for(; islower(c[j]) or isdigit(c[j]); j++)
- strncat(s[k], c+j, 1);
- i = j-1;
- for(int j=1; j<=k; j++)
- {
- strcat(aux, s[j]);
- if(j!=k)
- strcat(aux, "\\");
- }
- string str(aux);
- rez.insert(str);
- initializare(s[k]);
- k--;
- }
- else if(c[i] == ')')
- {
- initializare(s[k]);
- k--;
- }
- }
- fout << rez.size() << '\n';
- multiset<string>::iterator it;
- for(it = rez.begin(); it!=rez.end(); it++)
- fout << *it << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement