Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstring>
- using namespace std;
- ifstream fin("dir.in");
- ofstream fout("dir.out");
- char cuv[1605],sti[1605],linie;
- char ma[1005][100];
- int i,dr,o,q1,q2,nr,cuvinte;
- int main()
- {
- fin.get(cuv,1601);
- fin.get();
- cuvinte=0;
- i=0;
- nr=strlen(cuv);
- while (i<nr)
- {
- if (cuv[i]>=97 and cuv[i]<=122)
- {
- cuvinte++;
- while (cuv[i]>=97 and cuv[i]<=122)
- i++;
- }
- else
- i++;
- }
- fout<<cuvinte<<'\n';
- i=0;
- nr=strlen(cuv);
- dr=-1;
- linie=0;
- while (i<nr)
- {
- if (cuv[i]>=65 and cuv[i]<=89)/// or (cuv[i]>=48 and cuv[i]<=57))
- {
- while(cuv[i]!='(')
- {
- sti[++dr]=cuv[i];
- i++;
- }
- }
- if (cuv[i]>=97 and cuv[i]<=122)
- {
- o=0;
- linie++;
- while (cuv[i]!=',' and cuv[i]!=')')
- {
- ma[linie][o++]=cuv[i];
- i++;
- }
- }
- if (cuv[i]=='(')
- {
- sti[++dr]='\\';
- i++;
- }
- if (cuv[i]==',')
- {
- i++;
- }
- if (cuv[i]==')')
- {
- for (q1=1;q1<linie;q1++)
- {
- for (q2=q1+1;q2<=linie;q2++)
- {
- if (strcmp(ma[q1],ma[q2])>0)
- {
- swap(ma[q1],ma[q2]);
- }
- }
- }
- for (q1=1;q1<=linie;q1++)
- {
- fout<<sti<<ma[q1]<<'\n';
- }
- while(sti[dr]!='\\' and dr>-1)
- {
- dr--;
- }
- sti[dr]='\0';
- i++;
- while(sti[dr]!='\\' and dr>-1)
- {
- dr--;
- }
- if (dr>=0)
- sti[dr+1]='\0';
- linie=0;
- }
- }
- ///nr=strlen(cuv)
- /*p=strtok(cuv,"(");
- while (p!=NULL)
- {
- strcpy(sti,p);
- }*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement