Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<ctype.h>
  3. #include<string.h>
  4. #define N 1000
  5. int main()
  6. {
  7. char str[N];
  8. printf("input:");
  9. gets(str);
  10. char CopyStr[N];
  11. strcpy(CopyStr,str);
  12. printf("tokens:\n");
  13. char *tokens=strtok(CopyStr," ,.!?");
  14. while(tokens!=NULL)
  15. {
  16. printf("%s\n",tokens);
  17. tokens=strtok(NULL," ,?.!");
  18. }
  19. int i,BigAlpha[26]={0},SmallAlpha[26]={0};
  20. for(i=0;str[i]!='\0';i++)
  21. {
  22. if(isupper(str[i]))
  23. BigAlpha[str[i]-'A']++;
  24. if(islower(str[i]))
  25. SmallAlpha[str[i]-'a']++;
  26. else
  27. continue;
  28. }
  29. printf("Big Characters:\n");
  30. int b,counter=0;
  31. for(b=0;b<26;b++)
  32. {
  33. if(BigAlpha[b]>0)
  34. {
  35. printf("%c:%d ",b+'A',BigAlpha[b]);
  36. counter++;
  37. if(counter%5==0)
  38. puts("");
  39. }
  40. }
  41. puts("");
  42. printf("Small Characters:\n");
  43. int s,count=0;
  44. for(s=0;s<26;s++)
  45. {
  46. if(SmallAlpha[s]>0)
  47. {
  48. printf("%c:%d ",s+'a',SmallAlpha[s]);
  49. count++;
  50. if(count%5==0)
  51. puts("");
  52. }
  53. }
  54. puts("");
  55. system("pause");
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement