Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4245590
  • 博文数量: 1148
  • 博客积分: 25453
  • 博客等级: 上将
  • 技术积分: 11949
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-06 21:14
文章分类

全部博文(1148)

文章存档

2012年(15)

2011年(1078)

2010年(58)

分类: C/C++

2011-06-05 13:55:52

论坛帖:,看谁的快   实现

  1. #include<stdio.h>

  2. unsigned int count = 0;
  3. void judge_1(unsigned int data) //递归,从 高位到低位
  4. {
  5.     if(data != 0)
  6.     {
  7.         judge_1(data / 10);
  8.         if(data == 1)
  9.             count++;
  10.     }
  11. //    printf("count=%u\n",count);
  12. }

  13. void process(unsigned int n)
  14. {
  15.     while(n)
  16.     {
  17.         judge_1(n);
  18.         n--;
  19.     }
  20.     printf("\ncount=%u\n",count);
  21. }

  22. int main()
  23. {
  24.     unsigned int i = 13;
  25.     judge_1(i);
  26.     process(i);

  27.     return 0;
  28. }
阅读(866) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~