claudia529

十进制转二进制

void conversion()
{
    Stack S;
    int n;
    InitStack(&S);
    printf("Please input a number to convert:\n");
    scanf("%d",&n);
    if(n<0)
    {
        printf("The number must be over 0");
        return 0;
    }
    if(n==0)
    {
        Push(&S,n%2);
        n=n/2;
    }
    printf("The result is");
    while(!StackEmpty(&S))
    {
        printf("%d",Pop(&S));
    }
}

 

发表于 2019-06-28 16:41  江河湖海529  阅读(105)  评论(0编辑  收藏  举报
 

分类:

技术点:

相关文章:

  • 2021-12-04
猜你喜欢
  • 2021-12-19
  • 2022-01-09
  • 2021-08-11
  • 2022-12-23
  • 2021-04-28
  • 2021-05-24
  • 2021-12-04
相关资源
相似解决方案