首页 > 编程知识 正文

美国布克兄弟服装上海哪里有卖,布克烧水壶怎么调节水壶加水时间

时间:2023-05-06 09:10:51 阅读:215982 作者:2206

/* *播布客教学视频_C学习笔记_8.2_统计1到100中9的个数(函数) * *1.通过函数设计实现 *2.注释的写法 *紧贴代码上方 *代码右侧(变量说明) *多行注释(函数上方) * *author: syt<sytshanli@163.com> *create date: 2014.11.28 */#include<stdio.h>/* *count - count how many digit in num *@num: the number from 1 to 100 *@digit: digit can be 0,1,.... * *return value: the counter of digit in this num * *统计函数,如果digit是0那么会出现bug,把while改成do-while(后面必须加分号) */int count(int num,int digit){int count = 0;do{if(num % 10 == digit)count++;num /= 10;}while(num != 0);return count;}int main(void){int i = 0;int sum = 0; /*the sumary of 9*/int max = 0; /*the max number to count*/printf("sumary 9 from 1 to maxn");scanf("%d",&max);/*sumary 9 from 1 to max*//*for(i = 0;i <= 0;i++),counter(i,0),那么会出现bug */for(i = 1;i <= max;i++){sum += count(i,9);}printf("sum = %dn",sum);return 0;}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。