#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
struct Node
{
int numlinks;
std:: string name;
Node( int num, std:: string n) : numlinks( num) , name( n)
{
}
friend std:: ostream & operator<< ( std:: ostream & o, Node & node)
{
return o << node.name << " has " << node.numlinks << " links" ;
}
} ;
int main( )
{
std:: vector < std:: vector < Node> > distances;
//std::ifstream MyFile ("file.csv");
std:: istream & MyFile = std:: cin ;
//if(MyFile.is_open())
{
std:: string line;
while ( std:: getline ( MyFile, line) )
{
std:: istringstream row ( line) ;
distances.push_back ( std:: vector < Node> ( ) ) ;
std:: string cell;
while ( std:: getline ( row, cell, ',' ) )
{
int dist;
std:: istringstream ( cell) >> dist;
distances.back ( ) .push_back ( Node( dist, "name" ) ) ;
}
}
}
for ( std:: size_t i = 0 ; i < distances.size ( ) ; ++ i)
{
for ( std:: size_t j = 0 ; j < distances[ i] .size ( ) ; ++ j)
{
std:: cout << distances[ i] [ j] << ", " << std:: flush ;
}
std:: cout << std:: endl ;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnN0cmVhbT4KI2luY2x1ZGUgPHNzdHJlYW0+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDx2ZWN0b3I+CgpzdHJ1Y3QgTm9kZQp7CiAgICBpbnQgbnVtbGlua3M7CiAgICBzdGQ6OnN0cmluZyBuYW1lOwoKICAgIE5vZGUoaW50IG51bSwgc3RkOjpzdHJpbmcgbikgOiBudW1saW5rcyhudW0pLCBuYW1lKG4pCiAgICB7CiAgICB9CgogICAgZnJpZW5kIHN0ZDo6b3N0cmVhbSAmb3BlcmF0b3I8PChzdGQ6Om9zdHJlYW0gJm8sIE5vZGUgJm5vZGUpCiAgICB7CiAgICAgICAgcmV0dXJuIG8gPDwgbm9kZS5uYW1lIDw8ICIgaGFzICIgPDwgbm9kZS5udW1saW5rcyA8PCAiIGxpbmtzIjsKICAgIH0KfTsKIAppbnQgbWFpbigpCnsKICAgIHN0ZDo6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IsMyw0CjQsMywyLDEsMAo5LDgsNyw2LDUKNSw2LDcsOCw5Cg==
0,1,2,3,4
4,3,2,1,0
9,8,7,6,5
5,6,7,8,9
stdout
name has 0 links, name has 1 links, name has 2 links, name has 3 links, name has 4 links,
name has 4 links, name has 3 links, name has 2 links, name has 1 links, name has 0 links,
name has 9 links, name has 8 links, name has 7 links, name has 6 links, name has 5 links,
name has 5 links, name has 6 links, name has 7 links, name has 8 links, name has 9 links,