Reply to Re: C Programming Tutorial
If you don't have an account, just leave the password field blank.
Thanks. Here's the first one(I was too lazy to translate the second one too, but I'll do it). It's quite easy, but the second one was hard.
Problem 1:
In a group of n persons, there are pairs of persons considered friends. Considering my friend's
friend is my friend, identify all the groups made by exactly k persons that are friends(directly or
indirectly).
Input datos:
-k is read from the keyboard
-there is a file called graph.txt that contains on the first line n(the number of persons), and on
the next lines are pairs of numbers which represents the friendship relations.
Output datos:
-the results should be written in the file group.txt
-on each line, there should be written a group of persons
Examples:
k=3
graph.txt
9
1 2
4 5
2 3
7 8
7 9
group.txt (this way it should look)
1 2 3
7 8 9
k=2
graph.txt
3
1 2
2 3
group.txt(it shouldn't contain anything)
Problem 1:
In a group of n persons, there are pairs of persons considered friends. Considering my friend's
friend is my friend, identify all the groups made by exactly k persons that are friends(directly or
indirectly).
Input datos:
-k is read from the keyboard
-there is a file called graph.txt that contains on the first line n(the number of persons), and on
the next lines are pairs of numbers which represents the friendship relations.
Output datos:
-the results should be written in the file group.txt
-on each line, there should be written a group of persons
Examples:
k=3
graph.txt
9
1 2
4 5
2 3
7 8
7 9
group.txt (this way it should look)
1 2 3
7 8 9
k=2
graph.txt
3
1 2
2 3
group.txt(it shouldn't contain anything)