Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include<ctype.h>
- int main()
- {
- char a[1001];
- gets(a);
- int cnt[2001];
- memset(cnt,0,sizeof(cnt));
- int l=strlen(a),i;
- for(i=0; i<l; i++)
- cnt[(int)a[i]]++;
- puts("--by lexicographic order--");
- // by lexicographic order
- for(i=0; i<2001; i++)
- {
- if(cnt[i] && isalpha(i))
- {
- printf("%c had repeated for %d times\n",i,cnt[i]);
- }
- }
- puts("--by string order--");
- //by string order
- for(i=0; i<l; i++)
- {
- if(isalpha(a[i]) && cnt[(int)a[i]])
- {
- printf("%c has repeated for %d times\n",a[i],cnt[(int)a[i]]);
- cnt[(int)a[i]]=0;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment