标题:求指教,请各位看看这道题,在国外孤立无援。
取消只看楼主
hana_flower
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-7-22
结帖率:0
已结贴  问题点数:20 回复次数:0 
求指教,请各位看看这道题,在国外孤立无援。
Question:

generate two different random integers, s and t, which are different for each message. s is called the start code and t is called the end code.
The value of t is transmitted as the first integer in the encoded output. Then for every integer i in the message, the integer s is sent followed by a
randomly generated sequence L of 1 or more integers that sum to i with the constraint that neither s nor t appears in the sequence.

The entire message is terminated by a single t value. For example, if the message is 3, 21, 5 and the start and end codes are 11 and -91, the message might be transmitted as -91, 11, -1, 5, 2, -3, 11, 21, 11, 4, 0, 1 , -91 (where 3 is represented as -1 + 5 + 2 - 3, 21 is represented as itself and 5 is represented as 4 + 0 + 1).

Non-functional requirements: your program may not use arrays!

Input  
-91 11 -1 5 2 -3 11 21 11 4 0 1 -91

Output
3
21
5
Input
0 1 2 3 4 1 -1 -2 -3 0  

output
9
-6

拜托各位帮帮忙吧,我人在澳洲,刚到这边,没几个会编程的朋友,大部分都是学商科的,这个是学校的作业,我实在是不太明白怎么做。只能求教于网络了。拜托大家
搜索更多相关主题的帖子: generated single different sequence message 
2012-07-22 21:07



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-373903-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.213121 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved