Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #define MAX 1000
- int i;
- void letterFrequency (char *text, char letter){
- int count;
- float sum=0,BIG=0,small=0;
- if (isupper(letter)){
- letter = tolower(letter);
- }
- for (count=0;count<i;count++){
- //if (isalpha(*(text+count))){
- sum++;
- // }
- if (*(text+count)==letter){
- small++;
- }
- if (*(text+count)==letter-32){
- BIG++;
- }
- }
- printf("%c -> %.3f%%\n",letter,small/sum*100);
- printf("%c -> %.3f%%",letter-32,BIG/sum*100);
- }
- int main(){
- char niza[MAX];
- char c;
- int n,count;
- while ((c=getchar())!= '\n'){
- niza[i] = c;
- i++;
- }
- scanf("%c",&c);
- letterFrequency(niza,c);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement