#include <iostream> #include<vector> #include<list> #include<fstream> #include<cstring> using namespace std; const int n=6; struct graph { int vertices; char typ; char nodes[10]; } ; struct node { char str[10]; }; int main(int argc, char* argv[2]) { list<node> l; std::vector<list><node> > adjlist[n]; int i, degree[20]; char ch, ch1,ch2; struct graph g1; g1=new graph; ifstream fin; fin.open(argv[1]); fin>> g1.vertices; fin>>ch; fin>> g1.typ; for(i=0; i < g1.vertices-1 ; i++ ) { fin>> g1.nodes[i]; fin>>ch; } fin>>g1.nodes[i]; while(!fin.eof()) { fin>>ch; fin>>ch1; fin>>ch2; for(i=0; i<g1.vertices;> { if(g1.nodes[i]==ch) { degree[i]=degree[i]+1; adjlist[i].push_back(ch2); break; } } if(g1.typ=='u') { for(i=0; i<g1.vertices;> { if(g1.nodes[i]==ch2) { degree[i]=degree[i]+1; break; } } } } ofstream fout; fout.open(argv[2]); for(i=0; i< g1.vertices; i++) { fout<<g1.nodes[i]; fout<<"," ; fout<<degree[i]; fout<<"\n"; } fout.close(); fin.close(); return 0; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)