2

Code Detection Problem (Id-1529)

Bonus Practice Sheet Winter 2018 [17-Mar-2018 to 7-Apr-2018]

Program ID- 1529

For security reasons, messages are transmitted as a secret code over a transmission channel. It is usually sent as a sequence of bits, that is, 0s and 1s. Due to noise in the transmission channel, the transmitted message may become corrupted. That is, the message received at the destination may not be the same as the message transmitted. There are several techniques to check the validity of the transmitted message at the destination. One such technique is to transmit the same message twice. At the destination, both copies of the message are compared. Given a file “data.txt” with the messages that is transmitted, write a C++ program to check whether the message received at the destination is error-free. For simplicity, assume that the secret code representing the message is a sequence of digits(0 to 9) and the maximum length of the message is 250 digits. Each original message is followed by a copy message and first number in both the messages indcates the length of the message. Each character in the message is separated by a space. For example, 7 9 2 7 8 3 5 6 7 9 2 7 8 3 5 6 means that the original message is of length 7 and it is 9 2 7 8 3 5 6 and copy message is also of length 7 and it is 9 2 7 8 3 5 6. If orginal and copy message is same then print Message transmitted is ok. Print Message transmitted is not OK when th length of the original or copy message is greater than 250 or when the original message is not same as copy message.

Input Format:
Name of the file
Input file contains a number of secret codes immediately followed their copy

Output Format:
Print either Message transmitted is ok or Message transmitted is not ok

Code

Please Comment Working if the code worked to you

If you have other working codes please comment the codes enclosing with <pre> and </pre> 🙂

Example: <pre> Your Code </pre>

C++ Code 

The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

 

Click Here to Leave a Comment Below 2 comments
Drake - April 3, 2018

Thanksfor uploading this..still need both the vector operation codes as well




0



0

Reply
Shiashav - April 5, 2018

This code doesn’t work correctly.

Input:
data.txt

Expected output:
Message transmitted ok
Message transmitted not ok
Message transmitted ok

Your program output:
Message transmitted not ok
Message transmitted not ok
Message transmitted not ok
Message transmitted not ok
Message transmitted not ok
Message transmitted not ok




0



0

Reply

Leave a Reply:

This site uses cookies and by using the site you are consenting to this.