Get the App
SLTechnology News&Howtos  ›  Development  › 

How to splice the parity text content of C++

Shulou Source: shulou.com Published: 2022-06-01 01:38:32 09月29日 Update

This article mainly explains "how to splice the parity text of C++". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "how to splice the parity text content of C++".

The code is as follows:

@ echo off

Goto run

The problem is that there is a text file that contains the following contents

Accident

n. Unexpected encounter, accident; accident (factor)

Across

Prep. Across, over; opposite to ad. Across, through.

Active

Adj. Active, agile, active; active.

Advertise

Vt. To announce or announce; for. Advertise vi. Advertise

After

Prep. In.。 In the future; in. Adv in the back. Later, later.

How can I put it in another file that reads:

Accident n. Unexpected encounter, accident; accident (factor)

Across prep. Across, over; opposite to ad. Across, through.

Active adj. Active, agile, active; active.

Advertise vt. To announce or announce; for. Advertise vi. Advertise

After prep. In.。 In the future; in. Adv in the back. Later, later.

Conventional solution:

@ echo off

:: code by jm 2006-9-21 CMD@XP

Set / a num=1

Setlocal enabledelayedexpansion

For / f "tokens=*"% I in (1.txt) do (

Set / a num+=1

Set / a modulated numb% 2

If! mod! Equ 1 (set var=%%i) else (set str=%%i)

If! mod! Equ 1 echo! str!! var!

)

Pause

Goto: eof

The simplest and most efficient solution:

: run

@ echo off

:: code by 3742668 2006-9-21 CMD@XP

Setlocal ENABLEDELAYEDEXPANSION

For / f "delims="% I in (1.txt) do (

If "! str!" = "(set str=%%i

) else (

Echo! str! I

Set str=

)

)

Pause

At this point, I believe you have a deeper understanding of "how to splice the parity text content of C++". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Content accident parity Category Agility accident announcement Factor Advertising File solution Transcendence Learning activity practical Deep concise Code interest Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL vpn Linux Shulou Information Xiaomi