15题,字符串中大小写互换
批处理1- @echo off
- set "letters= abcdefghijklmnopqrstuvwxyzZYXWVUTSRQPONMLKJIHGFEDCBA"
- for /l %%a in (1,1,26) do call set /a "_%%letters:~%%a,1%%=%%a"
- :input
- setlocal EnableDelayedExpansion
- echo 请输入:&set /p var=&if not defined var endlocal&goto:input
- :loop
- set char=!var:~%pi%,1!
- set /a sn=_!char! 2>nul||set sn=0
- if defined char (
- if %sn% gtr 0 (
- if "!char!"=="!letters:~%sn%,1!" (set str=!str!!letters:~-%sn%,1!) else (set str=!str!!letters:~%sn%,1!)
- ) else (
- set str=!str!!char!
- )
- set /a pi+=1
- goto loop
- )
- echo=!str!
- pause&endlocal&goto input
复制代码 批处理2- @echo off & setlocal enabledelayedexpansion
- (for %%a in (a_A b_B c_C d_D e_E f_F g_G h_H i_I j_J k_K l_L m_M n_N o_O p_P q_Q r_R s_S t_T u_U v_V w_W x_X y_Y z_Z A_a B_b C_c D_d E_e F_f G_g H_h I_i J_j K_k L_l M_m N_n O_o P_p Q_q R_r S_s T_t U_u V_v W_w X_x Y_y Z_z) do echo;%%a)>temp.txt
- :loop
- cls&echo;输入混杂大小写的字母串(不超过15位)&set /p var=
- for /l %%b in (0,1,15) do (
- set "zifu=!var:~%%b,1!"
- if "!zifu!"=="" pause>nul&goto loop
- for /f "tokens=2 delims=_" %%c in ('findstr /b "!zifu!" temp.txt') do set /p=%%c<nul
- )
- pause&goto loop
复制代码
|