Click here to Skip to main content
15,887,214 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Access Violation Problem Pin
Waldermort9-Oct-07 1:01
Waldermort9-Oct-07 1:01 
GeneralRe: Access Violation Problem Pin
ashishbhatt9-Oct-07 1:13
ashishbhatt9-Oct-07 1:13 
AnswerRe: Access Violation Problem Pin
Hamid_RT9-Oct-07 1:02
Hamid_RT9-Oct-07 1:02 
Questionproblem in the customization of title bar Pin
anuragguptartm9-Oct-07 0:21
anuragguptartm9-Oct-07 0:21 
AnswerRe: problem in the customization of title bar Pin
Waldermort9-Oct-07 0:45
Waldermort9-Oct-07 0:45 
GeneralRe: problem in the customization of title bar Pin
anuragguptartm9-Oct-07 0:51
anuragguptartm9-Oct-07 0:51 
GeneralRe: problem in the customization of title bar Pin
toxcct9-Oct-07 1:54
toxcct9-Oct-07 1:54 
Questionhow do i juzt implement only topsort algo here Pin
snoop828-Oct-07 23:27
snoop828-Oct-07 23:27 
int numPaths;
bool bVisited;
vector<int> adjacent; // Contains the adjacent nodes in the INVERSE graph
};

sNode * nodes;
vector<int> topological; // Contains the REVERSED topological ordering of the nodes
int numNodes, bottomNode, numEdges;

void dfs(int);
void countPaths();
void printResults();

FILE * file;
FILE * outFile = NULL;

int main(int argc, char ** argv) {
int n, a, b;
char buf[256];
file = stdin;
if (argc == 2) {
file = fopen(argv[1], "r");
printf("Opening %s\n", argv[1]);
if (isdigit(argv[1][1]))
sprintf(buf, "%c%c.out", argv[1][0], argv[1][1]);
else
sprintf(buf, "%c.out", argv[1][0]);
printf("Opening %s\n", buf);
outFile = fopen(buf, "w");
}
fscanf(file, "%d%d%d", &numNodes, &bottomNode, &numEdges);
printf("%d nodes, %d edges\n", numNodes, numEdges);
nodes = new sNode [numNodes];
for (n = 0; n < numNodes; ++ n) {
nodes[n].numPaths = 0;
nodes[n].bVisited = false;
nodes[n].adjacent.clear();
}
for (n = 0; n < numEdges; ++ n) {
fscanf(file, "%d%d", &a, &b);
nodes[b].adjacent.push_back(a);
}
dfs(bottomNode);
if (topological.size() != numNodes) {
printf("ERROR: Not all nodes are reachable from the bottom\n");
return 0;
}
countPaths();
printResults();
system("PAUSE");
return 0;
}

void dfs(int current) {
int n;
queue<int> q;
vector<int> v;
if (nodes[current].bVisited)
return;
nodes[current].bVisited = true;
for (n = 0; n < nodes[current].adjacent.size(); ++ n)
dfs(nodes[current].adjacent[n]);
topological.push_back(current);
}

void countPaths() {
int n, i;
sNode * currentNode;

nodes[topological[numNodes - 1]].numPaths = 1;
for (n = numNodes - 1; n >= 0; -- n) {
currentNode = &nodes[topological[n]];
for (i = 0; i < currentNode->adjacent.size(); ++ i) {
if (INT_MAX - currentNode->numPaths < nodes[currentNode->adjacent[i]].numPaths)
printf("ERROR: OVERFLOW!\n");
nodes[currentNode->adjacent[i]].numPaths += currentNode->numPaths;
}
}
}

void printResults() {
int max, n;
max = nodes[0].numPaths;
for (n = 1; n < numNodes; ++ n)
if (nodes[n].numPaths > max)
max = nodes[n].numPaths;
printf("Node list: ");
for (n = 0; n < numNodes; ++ n) {
if (nodes[n].numPaths == max) {
printf(" (%d)", n);
if (outFile)
fprintf(outFile, "%d\n", n);
}
}
printf("\nPath count: %d\n", max);
if (outFile) {
fprintf(outFile, "%d\n", max);
fclose(outFile);
}
}
AnswerRe: how do i juzt implement only topsort algo here Pin
chandu0048-Oct-07 23:34
chandu0048-Oct-07 23:34 
GeneralRe: how do i juzt implement only topsort algo here Pin
toxcct9-Oct-07 0:16
toxcct9-Oct-07 0:16 
AnswerRe: how do i juzt implement only topsort algo here Pin
chandu0048-Oct-07 23:46
chandu0048-Oct-07 23:46 
QuestionRe: how do i juzt implement only topsort algo here Pin
David Crow9-Oct-07 2:54
David Crow9-Oct-07 2:54 
Question[SOLVED]how to enable intellisense Pin
chandu0048-Oct-07 23:08
chandu0048-Oct-07 23:08 
AnswerRe: how to enable intellisense Pin
Waleed Eissa8-Oct-07 23:54
Waleed Eissa8-Oct-07 23:54 
GeneralRe: how to enable intellisense Pin
chandu0049-Oct-07 3:04
chandu0049-Oct-07 3:04 
QuestionHide Member from Intellisense list Pin
Waleed Eissa8-Oct-07 22:55
Waleed Eissa8-Oct-07 22:55 
QuestionRe: Hide Member from Intellisense list Pin
chandu0049-Oct-07 3:05
chandu0049-Oct-07 3:05 
AnswerRe: Hide Member from Intellisense list Pin
Waleed Eissa9-Oct-07 18:08
Waleed Eissa9-Oct-07 18:08 
GeneralRe: Hide Member from Intellisense list Pin
chandu0049-Oct-07 18:24
chandu0049-Oct-07 18:24 
QuestionClient server interaction Pin
William Engberts8-Oct-07 22:46
William Engberts8-Oct-07 22:46 
AnswerRe: Client server interaction Pin
jhwurmbach9-Oct-07 1:19
jhwurmbach9-Oct-07 1:19 
QuestionBitmap-Histogram using MFC Pin
go9398-Oct-07 22:45
go9398-Oct-07 22:45 
AnswerRe: Bitmap-Histogram using MFC Pin
Waldermort9-Oct-07 1:13
Waldermort9-Oct-07 1:13 
AnswerRe: Bitmap-Histogram using MFC Pin
jhwurmbach9-Oct-07 1:16
jhwurmbach9-Oct-07 1:16 
GeneralRe: Bitmap-Histogram using MFC Pin
Chris Losinger9-Oct-07 3:13
professionalChris Losinger9-Oct-07 3:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.