Advertisement
Guest User

Untitled

a guest
Jun 27th, 2023
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int c,am[100], i, j, j2, found0;
  5. int sym[100];
  6. for(i = 0; i != 10; i++){
  7. sym[i]=0;}
  8. for(i = 0; i != 10; i++){
  9. am[i]=1;}
  10. i = 0;
  11. while((c=getchar()) != EOF){
  12. for(j=0; j < 10; j++){
  13. if(sym[j] == c){
  14. am[j]++;j=11;}//we checked if input symbol stored in any array element and if not>meaning we got to element 10 we do:
  15. else if(j == 9){
  16. found0 = 0;
  17. for(j2=0; found0 != 1&&j2!=10; j2++){
  18.  
  19. if(sym[j2] == 0){
  20. sym[j2]=c;
  21. j=j2;
  22. printf("sym[%d]=%c\n", j2, c);
  23. found0=1;}}}}}
  24. for(j = 0; j != 10; j++){
  25. if(sym[j] != 0){
  26. if(sym[j]=='\n')printf("Enter is used %d times\n", am[j]); else
  27. printf("%c,is used %d times\n", sym[j], am[j]);}}
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement