/*
Copyright (c) 2014,烟台大学计算机与控制工程学院
All rights reserved.
文件名称:test.cpp
作 者:张学伟
完成日期:2016年12月12日
版 本 号:v1.0
运行过程:
#include <stdio.h>
#include <stdlib.h>
int main()
{
char str[100];
gets(str);
char *ptr=str;
void fuction(char *);
fuction(ptr);
return 0;
}
void fuction(char s[100])
{
int i=0;
int a=0,b=0,c=0,d=0;
while(s[i]!='\0')
{
if(s[i]>='A'&&s[i]<='Z')
a++;
else if(s[i]>='a'&&s[i]<='z')
b++;
else if(s[i]>='0'&&s[i]<='9')
c++;
else
d++;
i++;
}
printf("%d\n%d\n%d\n%d\n%d",a,b,c,d,i);
}
运行结果:
知识点总结:统计字符串的种类。
学习心得注意输出的各种字符的顺序。