Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //String words frequecy
- #include<iostream>
- #include<string.h>
- char *W[100];
- int nr=0;
- int position=1;
- using namespace std;
- int words(char *str,char *A[]){
- char *delimitator=strtok(str," ");
- while(delimitator!=NULL){
- A[position]=delimitator;
- delimitator=strtok(NULL," ");
- position++;
- nr++;}
- cout<<"Sunt "<<nr<<" cuvinte : "<<endl;
- for(int i=1;i<=nr;i++){
- int frecventa=0;
- for(int j=1;j<=nr;j++){
- if(A[i]==A[j]){frecventa++;}}
- cout<<A[i]<<" "<<frecventa<<endl;}}
- int main(){
- char *theString=new char;
- cin.get(theString,100);
- words(theString,W);
- return 1;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement