啦啦啦拉拉裤 2021-09-26 16:24 采纳率: 69.1%
浏览 27
已结题

C语言,将 2 位 BCD 值转换为整数

请问这个应该要怎么解决?按照要求来写代码,在“PUT YOUR CODE HERE”写内容,例子旁边的#只是他的解释,蟹蟹大lao。题目如下。

img

img

img

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
int bcd(int bcd_value);
int main(int argc, char *argv[]) {
    for (int arg = 1; arg < argc; arg++) {
        long l = strtol(argv[arg], NULL, 0);
        assert(l >= 0 && l <= 0x0909);
        int bcd_value = l;
        printf("%d\n", bcd(bcd_value));
    }
    return 0;
}
// given a  BCD encoded value between 0 .. 99
// return corresponding integer
int bcd(int bcd_value) {
    // PUT YOUR CODE HERE
    return 0;
}
 

  • 写回答

1条回答 默认 最新

报告相同问题?

问题事件

  • 系统已结题 10月11日
  • 已采纳回答 10月3日
  • 创建了问题 9月26日