统计数字问题0

#include <iostream.h>
int main()
{
 void dev(int[],int);
 long int n,i;
 int a[10]={0};
 cin>>n;
 for(i=1;i<=n;i++)
 dev(a,i);//n次数

 for(i=0;i<10;i++)

 cout<<a[i]<<endl;
 return 0;
}
void dev(int array[],int number)
{
 int a,b,c,d,e,f,g,h;
 a=number/10000000;//10000000
 b=number/1000000%10;//1000000
 c=number/100000%10;//100000
 d=number/10000%10;//10000
 e=number%10000/1000;//1000
 f=number%1000/100;//100
 g=number%100/10;//10
 h=number%10;//个位
 if(a!=0)
 {array[a]++;array[b]++;array[c]++;array[d]++;array[e]++;array[f]++;array[g]++;array[h]++;}
 else if(b!=0)
 {array[b]++;array[c]++;array[d]++;array[e]++;array[f]++;array[g]++;array[h]++;}
 else if(c!=0)
 {array[c]++;array[d]++;array[e]++;array[f]++;array[g]++;array[h]++;}
 else if(d!=0)
 {array[d]++;array[e]++;array[f]++;array[g]++;array[h]++;}
 else if(e!=0)

{array[e]++;array[f]++;array[g]++;array[h]++;}
 else if(f!=0)
 {array[f]++;array[g]++;array[h]++;}
 else if(g!=0)
 {array[g]++;array[h]++;}
 else if(h!=0)
 {array[h]++;}
}

 

 

posted on 2009-05-08 15:07  whuzx  阅读(128)  评论(0编辑  收藏  举报

导航