Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. ///7. Sa se determine de cate ori se gaseste un cuvant intr-un text.
  2. #include<iostream>
  3. #include<string.h>
  4. #include<cstdio>
  5. using namespace std;
  6. int main()
  7. {
  8. char x[100];
  9. char y[100];
  10. cout<<"Text : ";gets(x);
  11. cout<<"Cuvant : ";cin>>y;
  12. char * pch;
  13. int cnt=0;
  14. pch = strtok (x," ,.-");
  15. while (pch != NULL)
  16. {
  17. if(!strcmp(pch,y)) cnt++;
  18. printf ("%s\n",pch);
  19. pch = strtok (NULL, " ,.-");
  20. }
  21. cout<<endl<<"Cuvinte : "<<cnt;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement