具体:从下面的文件内容中读取NUMBER-OF-NODES 后的值,并且判断如果这个值小于100则加5后替换掉原来的值,直到该值大于100,麻烦大神了
SIMULATION-TIME 40s
# The following is a random number seed used to initialize part of the seed of
# various randomly generated numbers in the simulation. This can be used to vary
# the seed of the simulation to see the consistency of the results of the
# simulation.
SEED 123
# The following two parameters stand for the physical terrain in which the nodes
# are being simulated. For example, the following represents an area of size 100
# meters by 100 meters. All range parameters are in terms of meters.
# Terrain Area we are simulating.
TERRAIN-DIMENSIONS (150, 150)
# The following parameter represents the number of nodes being simulated.
NUMBER-OF-NODES 50
# Terrain Area we are simulating.
TERRAIN-DIMENSIONS (150, 150)
ç»æµè¯å¯ç¨
æ件åå®ä¹ä¸ºtest.txt ä¿®æ¹ååå ¥åæ件
å¦éè¦å¯ä¿®æ¹
#define FILE_NAME "test.txt"
æé®é¢å
ä»ä¹é®é¢ï¼ æè¿è¾¹ç¨ä½ åçæµè¯æ件æ¯å¥½ç
test.txtåå§ç¨ä½ åç
æ§è¡å
MULATION-TIME 40s
# The following is a random number seed used to initialize part of the seed of
# various randomly generated numbers in the simulation. This can be used to vary
# the seed of the simulation to see the consistency of the results of the
# simulation.
SEED 123
# The following two parameters stand for the physical terrain in which the nodes
# are being simulated. For example, the following represents an area of size 100
# meters by 100 meters. All range parameters are in terms of meters.
# Terrain Area we are simulating.
TERRAIN-DIMENSIONS (150, 150)
# The following parameter represents the number of nodes being simulated.
NUMBER-OF-NODES 100
# Terrain Area we are simulating.
TERRAIN-DIMENSIONS (150, 150)
有问题啊,请问这是怎么回事啊?
test.txt和源文件同一目录
我和楼下的都是正确的,看来是你编译器有问题
test.txt和源文件不是同一目录,我写全test.txt的路径不行么?
追答可以,别写错就行,记得路径分隔符是\\
追问马上采纳您的,你楼上的感觉还是有问题,您的可以正常运行,但是我要在原来文件中修改,因为我要做一个完全自动化的东西,不能建立新文件,您能不能再修改一下,谢谢,如果你觉得麻烦,我在追加50分
追答#include<stdio.h>