Guest User

Untitled

a guest
Jan 17th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include<string.h>
  5. using namespace std;
  6. struct cuvinte{
  7. char *cuvant;
  8. int numar;
  9. };
  10.  
  11. int main()
  12. {
  13. cuvinte multime[100];
  14. ifstream f;
  15. f.open("input.txt");
  16. string str;
  17. while(getline(f,str))
  18. {
  19. char * cuvant = new char[str.size() + 1];
  20. char * abc = new char[str.size() + 1];
  21. copy(str.begin(), str.end(), abc);
  22. cuvant = strtok (abc," ,/_");
  23. while(cuvant!=NULL)
  24. {
  25. for(int i=0;i<10;i++)
  26. {
  27. cout<<cuvant;
  28. if(strcmp(cuvant,multime[i].cuvant)==0)
  29. multime[i].numar++;
  30. else
  31. {for(int j=0;j<10;j++)
  32. if(multime[j].numar==0)
  33. {multime[j].cuvant=cuvant;
  34. multime[j].numar=1;
  35. }
  36. }
  37. }
  38. cuvant = strtok ( NULL , " ");
  39. }
  40. }
  41.  
  42. return 0;
  43. }
Add Comment
Please, Sign In to add comment