; if(p->data[i]==asc_space)count++; } //计算空格数
while((p=p->next)!=null); //遍历 链表
return count;}
c、统计数字数
int count_num(line * &head){ //统计数字 数
line *p=head;
int count=0;
do
{ int len=strlen(p->data); //计算当前 data 里的数据元素的个数
for(int i=0;i<len;i++)
if(p->data[i]>=48 && p->data[i]<=57)count++;} //计算空格数
while((p=p->next)!=null); //遍历 链表
return count;}
d、统计文章的总字数
int count_all_word(line * &head){ //统计文章的总字数
line *p=head; //保存链表的首地址
int count=0; //总字母数
do
{count+=strlen(p->data);} //计算当前行内的字符数!除'\0'结束符外!注意,该统计包含“空格的长度!”
while((p=p->next)!=null); //遍历 链表
return count;}
3、 源代码
/*define macro variables */
#define true 1
#define false 0
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] 下一页