Advise a non-complex program (or task) with a meaning that will demonstrate all (or most) operations in programming (conditions, cycles, multiple choice, etc.)
Closed due to the fact that it is necessary to reformulate the question so that it is possible to give an objectively correct answer by the participants Athari , aleksandr barakin , LEQADA , Nick Volynkin ♦ , korytoff December 23, '15 at 7:00 .
The question gives rise to endless debates and discussions based not on knowledge, but on opinions. To get an answer, rephrase your question so that it can be given an unambiguously correct answer, or delete the question altogether. If the question can be reformulated according to the rules set out in the certificate , edit it .
- I would also look, however) - Sh4dow
- An ulcer you, however. =) - knes
- I, by the way, without irony. Just look at the minimum meaningful code, in which at least most operations (from if-else through bit operators, string comparison and procedures to interfaces / classes) would be interesting) The problem is even quite feasible, but I would be lazy) - Sh4dow
- “In programming” is unrealistic, the code, if by a miracle is possible, it will be cooler than a child of Frankenstein, so it will be difficult to talk about the meaning. Within the limits of one paradigm - it is possible and feasible. I'm not sure, but I would look at various implementations of interpreters / virtual machines. - drdaeman
- I catch the word. Out of harm at the exit I will write, so that I read everything. PHP, EC-no - knes
2 answers
In any complex program, all the operations listed by you will be. For example, a multiple choice ( switch
design) is convenient for analyzing user input (menu) or for creating a finite state machine for parsing a line (go along the line, look at each next character, depending on this symbol we translate the program into a particular state). Cycles - found almost everywhere. In particular, when it comes to working with arrays of the same type of data. For functions (and procedures, if there is a difference), a sufficiently large program can almost always be broken down. It is necessary to approach the question logically: select recurring operations in a function or frame as finished functions the program blocks to increase the readability of the code. I believe that we need a creative approach. As an interesting goal, take, for example, the creation of a game. You can make your implementation of Tetris. Another option - take an arbitrary textbook with examples of programs and look at the end :-)
Here's a task archive with a built-in compiler. You send them your code, they check and immediately say correctly what is wrong. There are about 1000 tasks, and all are very good, choose what your heart desires. P.S. I would recommend task number 1493 .