If the code is short, you can paste and copy it directly. If the code is too long, it is undoubtedly not suitable for direct copy and paste. You can choose to use pseudo code to describe the implementation process of your own program, and you can use ellipsis to omit the unimportant code in the middle and only write the processing of key logic.
The source code in the graduation thesis will be repeated, so it is necessary to pay attention to a small amount of paste and copy, and indicate the source, and indicate it in the references, preferably targeted quotations.