使用c ++搜索,创建旧文件 [英] searching, creating new file from old using c++

查看:56
本文介绍了使用c ++搜索,创建旧文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个C ++程序来搜索变量state!=

0在文本文件中,然后每次返回3个步骤以读取计数。

程序应该创建一个带有状态计数的新文件。旧的

文件中的数据是可变的,但可以如下:


old_file.txt

new_file.txt < br $>
州统计

州统计

0 22

1 83

0 83< ; -

1 13

0 13

1 34

0 34

1 33

1 33

1 23

1 31

1 66

1 23< -

3 63

1 66

3 37

0 45

3 88

1 22

3 66

1 98

3 3 6

0 13

0 73

0 53

0 63< -

0 37

0 88

3 66

3 36

3 33

3 88

3 67

0 45

0 35

0 44


我们将非常感谢任何帮助。


问候,

Michele

I would like to write a C++ program that searches for the variable "state !=
0" in a text file, and then go back 3 steps each time to read "count". The
program should create a new file with "state count". The data in the old
file is variable, but could be as follows:

old_file.txt
new_file.txt
state count
state count
0 22
1 83
0 83 <-
1 13
0 13
1 34
0 34
1 33
1 33
1 23
1 31
1 66
1 23 <-
3 63
1 66
3 37
0 45
3 88
1 22
3 66
1 98
3 36
0 13
0 73
0 53
0 63 <-
0 37
0 88
3 66
3 36
3 33
3 88
3 67
0 45
0 35
0 44

Any help will be greatly appreciated.

Regards,
Michele

推荐答案

对不起,格式搞砸了。


我想编写一个搜索变量的C ++程序

" state!= 0"在一个文本文件中,然后每次返回3个步骤来阅读

" count"。

程序应该创建一个带有状态计数的新文件。旧的

文件中的数据是可变的,但可以如下:


old_file.txt

州数

0 22

0 83< -

0 13

0 34

1 33

1 31

1 23< -

1 66

0 45

1 22

1 98

0 13

0 73

0 53

0 63< -

0 37

0 88

3 66

3 36
3 33

3 88

3 67

0 45

0 35

0 44

new_file.txt

1 83

1 13

1 34

1 33

1 23

1 66

3 63

3 37

3 88

3 66

3 36

任何帮助将不胜感激。


问候,

Michele


Michele and约翰" < pH值************** @ comcast.net>在留言中写道

news:xJ ******************** @ comcast.com ...
Sorry, the formatting is messed up.

I would like to write a C++ program that searches for the variable
"state != 0" in a text file, and then go back 3 steps each time to read
"count". The
program should create a new file with "state count". The data in the old
file is variable, but could be as follows:

old_file.txt
state count
0 22
0 83 <-
0 13
0 34
1 33
1 31
1 23 <-
1 66
0 45
1 22
1 98
0 13
0 73
0 53
0 63 <-
0 37
0 88
3 66
3 36
3 33
3 88
3 67
0 45
0 35
0 44

new_file.txt
1 83
1 13
1 34
1 33
1 23
1 66
3 63
3 37
3 88
3 66
3 36
Any help will be greatly appreciated.

Regards,
Michele

"Michele and John" <ph**************@comcast.net> wrote in message
news:xJ********************@comcast.com...
I想编写一个C ++程序来搜索变量state
!= 0。在文本文件中,然后每次返回3个步骤以读取计数。
程序应该创建一个带有状态计数的新文件。
旧文件中的数据是可变的,但可以如下:

old_file.txt
new_file.txt
状态计数
状态计数
0 22
1 83
0 83< -
1 13
0 13
1 34
0 34
1 33
1 33
1 23
1 31
1
1 23< -
3 63
1 66
3 37
0 45
3 88
1
3 66
1 98
3 36
0 13
0 73
0 53
0 63< ; -
0 37
0 88
3 66
3 36
3 33
3 88
3 67
0 45
0 35
0 44

任何帮助将不胜感激。

问候,
Michele
I would like to write a C++ program that searches for the variable "state != 0" in a text file, and then go back 3 steps each time to read "count". The
program should create a new file with "state count". The data in the old file is variable, but could be as follows:

old_file.txt
new_file.txt
state count
state count
0 22
1 83
0 83 <-
1 13
0 13
1 34
0 34
1 33
1 33
1 23
1 31
1 66
1 23 <-
3 63
1 66
3 37
0 45
3 88
1 22
3 66
1 98
3 36
0 13
0 73
0 53
0 63 <-
0 37
0 88
3 66
3 36
3 33
3 88
3 67
0 45
0 35
0 44

Any help will be greatly appreciated.

Regards,
Michele



2006年4月10日星期一22:38:14 -0400,Michele and John

< ph **** **********@comcast.net>在comp.lang.c中写道:
On Mon, 10 Apr 2006 22:38:14 -0400, "Michele and John"
<ph**************@comcast.net> wrote in comp.lang.c:
我想编写一个C ++程序来搜索变量state!=
0。在文本文件中,然后每次返回3个步骤以读取计数。
程序应该创建一个带有状态计数的新文件。旧
文件中的数据是可变的,但可以如下:
I would like to write a C++ program that searches for the variable "state !=
0" in a text file, and then go back 3 steps each time to read "count". The
program should create a new file with "state count". The data in the old
file is variable, but could be as follows:




[snip]


如果你想写一个C ++程序,为什么蓝色火焰你是

交叉发布到comp.lang.c?


它们是两种不同的语言,你知道,C ++在comp.lang.c中完全是关于主题的话题。


今后请更礼貌。


后续设置。


-

Jack Klein

主页: http://JK-Technology.Com

常见问题解答

comp.lang.c http://c-faq.com/

comp.lang.c ++ http:// www。 parashift.com/c++-faq-lite/

alt.comp.lang.learn.c-c ++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html



[snip]

If you want to write a C++ program, why the blue blazes are you
cross-posting to comp.lang.c?

They are two different languages, you know, and C++ is completely
off-topic in comp.lang.c.

Kindly be more polite in the future.

Followup set.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html




Jack Klein写道:

Jack Klein wrote:
On Mon,10 Apr 2006 22:38:14 -0400,Michele and John
< ph ******* *******@comcast.net>在comp.lang.c中写道:
On Mon, 10 Apr 2006 22:38:14 -0400, "Michele and John"
<ph**************@comcast.net> wrote in comp.lang.c:
我想编写一个C ++程序来搜索变量state!=
0。在文本文件中,然后每次返回3个步骤以读取计数。
程序应该创建一个带有状态计数的新文件。旧的
文件中的数据是可变的,但可以如下:
I would like to write a C++ program that searches for the variable "state !=
0" in a text file, and then go back 3 steps each time to read "count". The
program should create a new file with "state count". The data in the old
file is variable, but could be as follows:



[snip]

如果你想编写一个C ++程序,为什么蓝色火焰是你交叉发布到comp.lang.c?

它们是两种不同的语言,你知道,C ++完全是非主题的comp.lang.c.

将来要礼貌。

后续设置。



[snip]

If you want to write a C++ program, why the blue blazes are you
cross-posting to comp.lang.c?

They are two different languages, you know, and C++ is completely
off-topic in comp.lang.c.

Kindly be more polite in the future.

Followup set.




任何人还记得旧的反脾气暴行吗?

-

Nick Keighley



anyone remember the old anti-grumpiness campaign?
--
Nick Keighley


这篇关于使用c ++搜索,创建旧文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆