Coder and decoder

Discussion in 'Computer Science & Culture' started by Waiter_2001, Oct 20, 2014.

  1. Waiter_2001 Registered Senior Member

    Messages:
    459
    The following is a coder and a decoder. It works by going through every possible combination available using ASCII characters and assigns a number to that combination. This should make coding quite fun and simple. All that is needed is a length and a number.

    CODER:

    Code:
    CLS
    
    INPUT "MESSAGE:",M$
    
    L=LEN(M$)
    
    FOR A=1 TO L
    
    FOR B=32 TO 127
    
    C=C+1
    
    IF (MID$(M$,A,1)=CHR$(B)) THEN B=127
    
    CLS
    
    PRINT "LENGTH:";L
    
    PRINT C
    
    NEXT B
    
    NEXT A[
    
    
    DECODER:

    Code:
    INPUT "LENGTH:",L
    
    INPUT "N:"
    
    FOR A=1 TO L
    
    FOR B=32 TO 127
    
    C=C+1
    
    A$(A)=CHR$(B)
    
    IF (C=N) THEN FOR D=1 TO L
    
    PRINT A$(D)
    
    NEXT D
    
    END IF
    
    NEXT B
    
    NEXT A
     

Share This Page