【 C/C++学习笔记整理】--3.取数组中的其中一位,将其中几位组合起来

10.定义一个数组,取数组中的其中几位,将其中几位组合起来

const int f[10]={6,2,5,5,4,5,6,3,7,6};
int match(int num)
{
    int k=0;
    for(int i=num;i!=0;i/=10)
        k+=f[i%10];
    if(num==0) k+=f[0];
    return k;
}

  int match1 lx(int cn)
{
    short sm = 0;
    do
    {
        sm += cl[cn % 10];
        cn /= 10;
    } while (cn != 0);
    return sm;
}

猜你喜欢

转载自blog.csdn.net/wxq_1993/article/details/85292404