Greetings, programmers. There is a question, a task has been received: it is as easy as possible to integrate several laboratory works in a console application. How best to implement this? The kind of idea is this. The person writes the job number and it is executed. If it is possible, then with reference to the example.

    1 answer 1

    The easiest:

    var num: integer; begin write("Π’Π²Π΅Π΄ΠΈΡ‚Π΅ Π½ΠΎΠΌΠ΅Ρ€ задания: "); readln(num); if num=156 then begin {ΠΈΠ΄Π΅Ρ‚ ΠΊΠΎΠ΄ задания 156} end; if num=223 then begin {ΠΈΠ΄Π΅Ρ‚ ΠΊΠΎΠ΄ задания 223} end; if num=718 then begin {ΠΈΠ΄Π΅Ρ‚ ΠΊΠΎΠ΄ задания 718} end; if num<>156 AND num<>223 AND num<>718 then begin writeln("Π’Π°ΠΊΠΎΠ³ΠΎ задания Π½Π΅Ρ‚."); readln(); end; end. 

    A more complicated way is through procedures and functions. =)

    UPD : Case will not save much =)

     case num of '156' : begin {ΠΈΠ΄Π΅Ρ‚ ΠΊΠΎΠ΄ задания 156} end; '223' : begin {ΠΈΠ΄Π΅Ρ‚ ΠΊΠΎΠ΄ задания 223} end; '718' : begin {ΠΈΠ΄Π΅Ρ‚ ΠΊΠΎΠ΄ задания 718} end; else begin writeln("Π’Π°ΠΊΠΎΠ³ΠΎ задания Π½Π΅Ρ‚."); readln(); end; end; 
    • Yes, the problem is that each task has its own specifics, and it will have to be heavily piled up. I have seen the implementation somewhere through the case, but I still cannot find where. What is - either difficult or not suitable, but an elementary-optimal solution is needed ) - VaLenOK007
    • Added by. In your case, Case will not greatly simplify the situation ... - knes
    • one
      Replace the word otherwise with else (there are no otherwise words in Pascal). - DelphiM0ZG
    • Um ... confused with something, isn't it? Okay thank you. - knes