Hey guys, I'm new here, I looked through the help also searched and couldn't find anything that helped. Although I will be using the Algorithms you guys have on this site.
anyways I only took a intro course to C++ about four years ago and don't remember much I wrote a program for a class and I can't get it to work I feel as though I am missing something.
What I'm trying to do is have the programs prompt the user for a node. Then the program refrence a text file with four coloums and x amount of nodes (I'll post the numbers i have). and it post all the row's that match that number.
Here's what I have so far
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int i = 0;
int a;
int head[16];
int tail[16];
int capacity[16];
int cost[16];
int count;
ifstream inFile;
// initalize the text file, and make sure it works
inFile.open("fstarin.txt");
if (!inFile)
{
cout << "Unable to open file"<<endl;
exit(1);
// terminate with error
}
for (count= 0; count< 16; count = count++)
{
// input so it knows what each collum stands for
inFile>>tail[count]>>head[count]>>cost[count]>>capacity[count];
}
// enter node
cout<<"enter a node"<<endl;
cin>>a;
// output node info regarding what node was entered
for (i=0;i<15;i++)
if (tail[i]==a)
{
cout<<tail<<head<<cost<<capacity<<endl;
}
return 0;
}
The text file is this
1 2 2 4
1 3 3 7
2 4 2 6
2 5 6 8
2 6 8 8
3 2 5 5
3 5 3 8
3 8 5 9
4 3 2 4
4 5 3 4
4 6 3 9
4 7 1 5
5 7 6 4
5 8 1 2
7 6 1 5
8 7 2 9
So for example what I'm trying to get it to do is if user enters 3 as the node in the prompt, it will display
3 2 5 5
3 5 3 8
3 8 5 9
If possible I would like to try and figure out how to have it display the titles on top of the numbers... for example
Tail Head Cost Capacity
3 2 5 5
3 5 3 8
3 8 5 9
Thanks for your guy's help!!