Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(void){
- float abs_freq[256];
- int i,chr,count = 0;
- for (i = 0; i < 255; i++)
- abs_freq[i] = 0;
- while ((chr = getchar()) != EOF){
- abs_freq[(int)chr]++;
- count++;
- }
- for (i = 0; i < 255; i++){
- if (abs_freq[i] != 0){
- if (i == '\n'){
- printf("\n\\n");
- printf(" absolute frequency %3.0f", abs_freq[i]);
- printf(" relative frequency %0.3f", abs_freq[i]/count);
- }
- if (i == '\t'){
- printf("\n\\t");
- printf(" absolute frequency %3.0f", abs_freq[i]);
- printf(" relative frequency %0.3f", abs_freq[i]/count);
- }
- if (i != '\n' && i != '\t'){
- printf("\n %c", i);
- printf(" absolute frequency %3.0f", abs_freq[i]);
- printf(" relative frequency %1.3f", abs_freq[i]/count);
- }
- }
- }
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement