Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int c,am[100], i, j, j2, found0;
- int sym[100];
- for(i = 0; i != 10; i++){
- sym[i]=0;}
- for(i = 0; i != 10; i++){
- am[i]=1;}
- i = 0;
- while((c=getchar()) != EOF){
- for(j=0; j < 10; j++){
- if(sym[j] == c){
- 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:
- else if(j == 9){
- found0 = 0;
- for(j2=0; found0 != 1&&j2!=10; j2++){
- if(sym[j2] == 0){
- sym[j2]=c;
- j=j2;
- printf("sym[%d]=%c\n", j2, c);
- found0=1;}}}}}
- for(j = 0; j != 10; j++){
- if(sym[j] != 0){
- if(sym[j]=='\n')printf("Enter is used %d times\n", am[j]); else
- printf("%c,is used %d times\n", sym[j], am[j]);}}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement