These are the directions and I am profusely confused. You are intrigued by these social networking websites and want to know how they work. You started with figuring out your school’s social network. You want to know who is friends with who and how many friends each person has. Write a program that shows a two dimensional array of friends where each element taking a value of either 1 or 0 representing whether the person at row i is friends with person at column j. Your program should also output the number of friends each person has. Procedure 1. Ask the user to enter the total number of people in the network to create the 2-D array. 2. Store their names in a separate array. 3. For now, we are going to randomly decide whether one person is friends with another • This means person A is friends with person B with 50% chance. • Also note, if person A is friends with B, then B is friends with A. 4. Populate the 2-D array with 1 representing row i and column j being friends and 0 representing row i and column j not being friends. 5. You should assume that you are not friends with yourself, which means that ArrayOfFriends[i][j] = 0, where i = j. 6. Output the 2-D array to the screen (neatly spaced). 7. Also output the total number of friends each person has (calculate using the 2-D Array).
Aucun commentaire:
Enregistrer un commentaire