Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. //String words frequecy
  2.  
  3. #include<iostream>
  4. #include<string.h>
  5.  
  6. char *W[100];
  7. int nr=0;
  8. int position=1;
  9. using namespace std;
  10.  
  11. int words(char *str,char *A[]){
  12. char *delimitator=strtok(str," ");
  13. while(delimitator!=NULL){
  14. A[position]=delimitator;
  15. delimitator=strtok(NULL," ");
  16. position++;
  17. nr++;}
  18. cout<<"Sunt "<<nr<<" cuvinte : "<<endl;
  19. for(int i=1;i<=nr;i++){
  20. int frecventa=0;
  21. for(int j=1;j<=nr;j++){
  22. if(A[i]==A[j]){frecventa++;}}
  23. cout<<A[i]<<" "<<frecventa<<endl;}}
  24.  
  25. int main(){
  26. char *theString=new char;
  27. cin.get(theString,100);
  28. words(theString,W);
  29. return 1;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement