美文网首页
2019-05-05

2019-05-05

作者: 幻无虚生 | 来源:发表于2019-05-05 10:32 被阅读0次

数字特征值

image.png
  • 0 是偶数
#include <stdio.h>
int main(){
    int number = 0;
    scanf("%d",&number);
    int stage =0;
    int a=0;
    int b=0;
    int c=0;
    int d=0;
    int e=1;
    int count=0;
    int sum=0;
    while(number>0){
        count++;
        a = number%10;  
        number=number/10;
        if(a>0)
        {
            if((a%2==count%2))
                {
                    b=1;
                }
            else
                {
                    b=0;
                }
        }
        else
        {  
            if((a%2==count%2))
                {
                    b=1;
                }
            else
                {
                    b=0;
                }   
         }
         if(count==1){
            d=b*1;
        }else{  
            e=e*2;
            d=d+(b*e);
        }
         
          
    }
    printf("%d",d);
    return 0;
}

相关文章

网友评论

      本文标题:2019-05-05

      本文链接:https://www.haomeiwen.com/subject/pjhcoqtx.html