1. 顺序结构模式:
@echo off
echo Hello, World!
pause
exit

这个程序从上到下依次执行,先输出"Hello, World!",然后暂停等待用户按下任意键,最后退出。

  1. 选择结构模式:
@echo off
set /p choice="Do you want to return to DOS? (Y/N): "

if /i "%choice%"=="Y" (
    exit
) else (
    echo Returning to program...
    pause
    goto :start
)

:start
echo This is the start of the program.
pause
exit

这个程序将用户的选择存储在choice变量中,并使用条件语句判断用户的选择。如果用户输入"Y",则直接退出程序返回到DOS;否则,输出"Returning to program...",暂停等待用户按下任意键,然后跳转到标签:start重新开始程序的执行。

写出两种返回DOS的程序结构模式语句

原文地址: https://www.cveoy.top/t/topic/hUvS 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录