Hi, I have the following problem:
Text file "strlines.dat" contains series of the following information of straight lines:
1) coordinate of one line's point
2) angle slope
It looks like (x,y) 45 deg:
2,6 60
4,7 45
2,1 30
After adding this information to associative container verify it and find lines
1) with same coordinates
2) with same angles
Showing results separately for each 1) and 2).
How to add info from file to associative container and find it? It should be like this?:
#include <string.h>
#include <iostream>
#include <map>
#include <utility>
typedef std::pair<std::(int, int), std::int> strlines;
int main(){
// straight line is defined by:
// 1) coordinate of one line's point
// 2) angle slope
map<int, string> Line; // associative array
map<int,string>::iterator it; // iterator for access to Lines
Line.insert(strlines.dat);
for(it= Line.begin(); it!= Line.end(); ++it){
cout <<"Point's coordinate: : "<< (*it).first << " Angle slope of line: " << (*it).second << endl;
// Verify if coordinates of some points are identical
if((it=Line.find()) == Line.end()){
std::cout<<"Point's coordinate: "<< (*it).first<<" Angle slope of line: " << (*it).second << endl;
} else{
cout << "No lines with similar coordinates";
}
return 0;
}