Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4. using namespace std;
  5. ifstream fin("dir.in");
  6. ofstream fout("dir.out");
  7. char cuv[1605],sti[1605],linie;
  8. char ma[1005][100];
  9. int i,dr,o,q1,q2,nr,cuvinte;
  10. int main()
  11. {
  12. fin.get(cuv,1601);
  13. fin.get();
  14. cuvinte=0;
  15. i=0;
  16. nr=strlen(cuv);
  17. while (i<nr)
  18. {
  19. if (cuv[i]>=97 and cuv[i]<=122)
  20. {
  21. cuvinte++;
  22. while (cuv[i]>=97 and cuv[i]<=122)
  23. i++;
  24. }
  25. else
  26. i++;
  27. }
  28. fout<<cuvinte<<'\n';
  29. i=0;
  30. nr=strlen(cuv);
  31. dr=-1;
  32. linie=0;
  33. while (i<nr)
  34. {
  35. if (cuv[i]>=65 and cuv[i]<=89)/// or (cuv[i]>=48 and cuv[i]<=57))
  36. {
  37. while(cuv[i]!='(')
  38. {
  39. sti[++dr]=cuv[i];
  40. i++;
  41. }
  42. }
  43. if (cuv[i]>=97 and cuv[i]<=122)
  44. {
  45. o=0;
  46. linie++;
  47. while (cuv[i]!=',' and cuv[i]!=')')
  48. {
  49. ma[linie][o++]=cuv[i];
  50. i++;
  51. }
  52. }
  53. if (cuv[i]=='(')
  54. {
  55. sti[++dr]='\\';
  56. i++;
  57. }
  58. if (cuv[i]==',')
  59. {
  60. i++;
  61. }
  62. if (cuv[i]==')')
  63. {
  64. for (q1=1;q1<linie;q1++)
  65. {
  66. for (q2=q1+1;q2<=linie;q2++)
  67. {
  68. if (strcmp(ma[q1],ma[q2])>0)
  69. {
  70. swap(ma[q1],ma[q2]);
  71. }
  72. }
  73. }
  74. for (q1=1;q1<=linie;q1++)
  75. {
  76. fout<<sti<<ma[q1]<<'\n';
  77. }
  78. while(sti[dr]!='\\' and dr>-1)
  79. {
  80. dr--;
  81. }
  82. sti[dr]='\0';
  83. i++;
  84. while(sti[dr]!='\\' and dr>-1)
  85. {
  86. dr--;
  87. }
  88. if (dr>=0)
  89. sti[dr+1]='\0';
  90. linie=0;
  91. }
  92. }
  93. ///nr=strlen(cuv)
  94. /*p=strtok(cuv,"(");
  95. while (p!=NULL)
  96. {
  97. strcpy(sti,p);
  98.  
  99. }*/
  100. return 0;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement