谁帮我编个C的程序,万分感谢

来源:百度知道 编辑:UC知道 时间:2024/06/05 20:39:40
有一篇文章,共1行,80个字符,要求分别统计出其中英文大写字母,小写字么,数字,空格以及其他字符的个数
用一维数组

这个是利用char的数值对比实现的..是一个java程序..可以在里面实现你所要的那种效果,希望你看得懂,我是直接在主函数中写了..你可以自己分离代码出来..
public static void main(String[] args){
int chlow=0,chup=0,num=0,space=0,other=0;
String str = "this \tis my word -01239 !!";//测试的字符串;
char[] chArr = str.toCharArray();
for(int i=0;i<chArr.length;i++){
char c = chArr[i];
if(c<58 && c>=48){
num++;
}
else if(c>=65 && c<90 ){
chlow++;
}
else if(c>=97 && c<=122){
chup++;
}
else if((c>=28 && c<=32) || (c==9 || c==10 || c==13)){
space++;
}
else{
other++;
}
}
System.out.println("chlow = "+chlow+"\nchup = "+chup+"\nnum = "+num+"\nspace = "+space+"\nother= "+other);
}

int A=0;
int a=0;
int n=0;
int s=0;

先用char text[80]保存这80个字符
int p=text;
for (int i=0;i<80;++i) {
if (*p