• Forum
  • Jobs
  • Finding the relation of ransitivity in c

 
Finding the relation of ransitivity in c++

Hi every one, I’m trying to apply the transitivity in c ++, the input will be from txt file as two column such that:
1 A
1 C
2 B
3 A
2 C
4 B
3 D
4 D

The result in txt file would be from primary column (first one) as :

1 3
1 2
2 4
2 1
3 1
3 4
4 2
4 3

I used vector to put all values in, what is the efficient way to do that.


#include<iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <cctype>
#include<vector>
#include <cstring>







using namespace std;

int main()
{
int element_size_x=0 ; // the size of first coluom
int element_size_y=0 ; // the size of second coloumn
ifstream file("file.txt");

vector <string> x,y;

while (getline(file, line))
{ int a, b ;
istringstream ss(line);
if (!(ss >> a >> b ))
{

break;
}

x.push_back(a);
y.push_back(b);
}

element_size_x = x.size();
element_size_y = y.size();

}

I offer 20 dollar for who can do this.
Last edited on
I have the solution!
Job is done,

Thanks guys
Topic archived. No new replies allowed.