1,1标准输入读入字符,统计各类字符所占百分比
#include <stdio.h>
#include <ctype.h>
//不可打印字符
int isunprint(int ch){
return !isprint(ch);
}
//转换表,储存各个判断函数指针
int (*tables[])(int) = {iscntrl, isspace, isdigit, islower, isupper, ispunct, isunprint};
int main()
{
int count[7] = {0};
int ch;
int idx;
while((ch = getchar()) != EOF){
//转换表中的函数进行测试,如果符合对应的数组项+1
for(idx = 0; idx < 7; idx++){
if(tables[idx](ch)){
count[idx]++;
}
}
}
for(idx = 0; idx < 7; idx++){
printf("%d\n", count[idx]);
}
return 0;
}
运行结果:

1.4 编写sort函数,对任何类型数组进行排序
原文:http://www.cnblogs.com/yangxunwu1992/p/5854519.html