[align=center]Letter [/align] | [align=center]Occurrence [/align] | [align=center]Percentage [/align] | |
[align=center]--------- [/align] | [align=center]------------------ [/align] | [align=center]----------------- [/align] | |
[align=center]A [/align] | [align=right]4 [/align] | [align=right] [/align] | [align=center]8% [/align] |
[align=center]B [/align] | [align=right]1 [/align] | [align=right] [/align] | [align=center]2% [/align] |
[align=center]C [/align] | [align=right]1 [/align] | [align=right] [/align] | [align=center]2% [/align] |
[align=center]D [/align] | [align=right]2 [/align] | [align=right] [/align] | [align=center]4% [/align] |
[align=center]E [/align] | [align=right]12 [/align] | [align=right] [/align] | [align=center]25% [/align] |
[align=center]F [/align] | [align=right]1 [/align] | [align=right] [/align] | [align=center]2% [/align] |
[align=center]G [/align] | [align=right]1 [/align] | [align=right] [/align] | [align=center]2% [/align] |
[align=center]H [/align] | [align=right]3 [/align] | [align=right] [/align] | [align=center]6% [/align] |
[align=center]I [/align] | [align=right]2 [/align] | [align=right] [/align] | [align=center]4% [/align] |
[align=center]K [/align] | [align=right]1 [/align] | [align=right] [/align] | [align=center]2% [/align] |
[align=center]L [/align] | [align=right]1 [/align] | [align=right] [/align] | [align=center]2% [/align] |
[align=center]N [/align] | [align=right]2 [/align] | [align=right] [/align] | [align=center]4% [/align] |
[align=center]O [/align] | [align=right]2 [/align] | [align=right] [/align] | [align=center]4% [/align] |
[align=center]R [/align] | [align=right]1 [/align] | [align=right] [/align] | [align=center]2% [/align] |
[align=center]S [/align] | [align=right]2 [/align] | [align=right] [/align] | [align=center]4% [/align] |
[align=center]T [/align] | [align=right]4 [/align] | [align=right] [/align] | [align=center]8% [/align] |
[align=center]V [/align] | [align=right]2 [/align] | [align=right] [/align] | [align=center]4% [/align] |
[align=center]W [/align] | [align=right]6 [/align] | [align=right] [/align] | [align=center]13% [/align] |
下面是我写的第一部分,转换成大写字母.,请教大侠们,怎么算字母出现频率和百分比
#include <stdio.h>
#include <stdlib.h>
#include < string.h>
void ToUpper (int);
void PrintResult ( int);
char a[80];
void main ()
{
int c;
printf("please enter a string\n");
gets(a);
while( c !=0)
{
ToUpper( c);
//PrintfResult ( c);
printf("please enter a string\n");
gets(a);
}
}
void ToUpper ( int c)
{
int i;
long l;
l=strlen(a);
for(i=0; i<l;i++)
if (a[i]>96 &&a[i]<123)
a[i]=a[i]-32;
puts(a);
}