开发者

reading two consecutive integer and then its weight

I have a program which reads a integer from a file, as given below.

value1 and value2 are to be taken from user.

path file contains the weight of path, lets say weight of path 1 to 3 is 4 and 5 to 6 is 3, then path file will be:

path

1 3 4

5 6 1

3 2 1

The code is:

fp=fopen("path","r");

while(fscanf(fp,"%d",i)==1)
{
  if(((j==value1)&&(i==value2开发者_开发知识库))||((j==value2)&&(i==value1)))
    weight={next value which will be read};
}

I want the logic to read the above weight

Also, while scanning the file it should not take the third integer of each line.

For example, if I want path between 1 to3 then it should not scan the 1 or 3 which is in third coloum.

The framing of this doubt is quite difficult, but I will try to make it clear if anybody of you wish to help me.


I'm not a expert in C language but the third parameter of the function fscanf expected a memory address, if the variable i is a integer, you need to use &i ok?

http://www.cplusplus.com/reference/clibrary/cstdio/fscanf/

I'm sorry because for anything. lol .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜