Pages

Wednesday, October 26, 2011

Sunday, September 18, 2011

Download Visual Studio 2006 Free

Download Visual Studio 2006 Free and Install Using Custom Settings.

click here to download

Wednesday, July 13, 2011

Difference between BFS and DFS


Breadth-first search (BFS) and depth-first search (DFS) are the two algorithms used for traversing and searching a node in a graph. They can also be used to find out whether a node is reachable from given node or not.
In depth-first search traversal  we try to go far from the root node.  Nodes are visited by going through the depth of the tree from starting node. When we reach at the node which does not have any children then we backtrack and visit the child nodes on another branch.
The depth-first search traversal of above graph will be:

A  B  E  F  C  D

Tuesday, June 14, 2011

An Introduction to Programming Contest (Various Input\Output Systems)

If you are a beginner, you will find it very unusual sometime regarding taking inputs. Some problems will say, "The Program will continue till the END OF FILE:, some will say "Stop taking input if N=0" etc etc. Some important ways to take input will be described here:

1. If you are said to take an integer number (n) as input till the End Of File/ (EOF):
 
 
int main(){
    int n;
    while(scanf("%d", &n)!=EOF){
         ...........
         ...........
    }
    return 0;
}

Sunday, June 5, 2011

File Input/Output

There are various ways to take input from file and show the result in another file. 

We can use fopen() for taking input from a file or to show output in a file. It is the easiest way to do so. First, we have to open the files and at the end we just need to close the file. An example is given below:

Suppose we want to take input from the "input.txt" file and want to store the results in the "output.txt" file. The code for this is given below:

#include<stdio.h>
int main(){
    int T, ans;
    int cm, y, ssu, ssa, f;
    int b, gs, gc, w;
    freopen("input.txt","r", stdin);
    freopen ("output.txt","w",stdout);
    scanf("%d", &T);
    while(T--){
               scanf("%d%d%d%d%d", &cm, &y, &ssu, &ssa, &f);
               scanf("%d%d%d%d", &b, &gs, &gc, &w);
               ans = b + (gs/30) + (gc/25) + (w/10);
               printf("%d\n", ans);
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}