please在c语言中的意义,C语言测试题一Problem-PleasewriteCprog 爱问知识人

[Problem] Please write C program according to the following condition(Test time : 4hours)【问题】请根据以下条件写出C程序(测试时间:4小时)There is Morse code

[Problem] Please write C program according to the following condition(Test time : 4hours)【问题】请根据以下条件写出C程序(测试时间:4小时)There is Morse code which consists of ‘0’s and ‘1’s as a bitstream. This code starts with 1 as start-bit, which follows 8 data-bit with 1 or 0, ends with 0 as stop-bit. Find the rule as follows.这就是摩斯码,包含0和1的比特序列;这种编码以“1”作为起始位开始,后面跟随8位“0”或者“1”,最后以“0”结束;可以从以下找到规则; In the below example, between the start-bit and stop-bit, there are 8 data-bit,0 0 1 0 1 0 1 1. We can convert this data-bit into decimal number, the result is 43.在下面的例子中,在开始位和结束位中间;共有8位数字:00101011;我们可以把他转换为10进制数字为43; Example) Binary digit 00101011 (Decimal: 43)Following these two steps, write a program which returns the result.按照下面两步,写出程序返回结果;Step 1) There is 10,000 bit stream in main.cpp. Find the Morse code from the beginning of bit stream to end and convert the binary digit into decimal number. (Check it from data[0] to data[9999] sequentially)步骤1)在main.cpp中有个10,000的比特流;从开始位到结束位找出摩斯码;并且把二进制数字(我个人觉得是中间八位)转换为10进制数字;(依次从data[0]到data[999]检查)Step 2) The converted decimals has the range from 0 to 255.Calculate the frequency of the decimal numbers and returns the number which has higher frequency among 256 numbers. If there are tie, return the larger number.步骤2) 转换完之后的数字范围从0到255.计算出十进制数字的频率,并且返回256个数字中频率最高的;如果有相当的,就返回较大的数字;Note) Below 30 bit stream, there are two Morse code,1000111110and1100011110, which converts into 31 and 143注意)下面30为数字中,有两个摩斯码,1000111110and1100011110转换成十进制为 31和 143 1110[Implementation Function]Int test_main(int data[SIZE]);Return: the number of higher frequency (0~255, if there are tie, result should be the larger number.)[Attachment 1 – single_id.cpp]// DD NOT INCLUDE ANY FILES#defineSIZE 10000inttest_main(intdata[SIZE]){ return 0; // the number of higher frequency}[Attachement 2 – main.cpp]#include#include#defineSIZE 10000inttest_main(intdata[SIZE]);static int data[SIZE];void build_data(void){ for (intc = 0; c

展开

全部

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值