Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to splice the parity text content of C++

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report