Pages

Sunday, October 31, 2010

Setting up Eclipse for C++ in Windows

Help -> Software Updates


Add a new site
http://download.eclipse.org/tools/cdt/releases/helios


Then follow the normal instructions.


I don't know why even I am adding this as a blog post.

Sunday, October 24, 2010

Java Program to print all links in the specified URL

import java.net.*;
import java.util.StringTokenizer;
import java.io.*;

public class ReadURL 
{
    public static void main(String[] args) throws Exception 
    {
    URL yahoo = new URL("http://aintmeekcoder.blogspot.com");
    BufferedReader in = new BufferedReader(new InputStreamReader(yahoo.openStream()));
    String inputLine;
    int loc;
    while ((inputLine = in.readLine()) != null)
        {
            if ((loc=inputLine.indexOf("
            {
                for (int i=loc+9; inputLine.charAt(i)!='>'; i++)
                {
                    System.out.print(inputLine.charAt(i));
                }
                System.out.println();
            }
        }
    in.close();
    }
}

Tuesday, October 19, 2010

352 Seasonal War Uva Online Judge

Problem: http://uva.onlinejudge.org/external/3/352.html
My Approach:


  • Traverse all elements starting from 0,0
  • Check whether the element is one
    • If it is the applydfs
      • applydfs
        • if it is one, mark it as 0
        • apply the same to all its unvisited neighbours
        • if zero, return
    • count the no. of times dfs is applied
    • this will count the number of connected components
    • And thus we have our answer



784 Maze Exploration Uva Online Judge

Points to remember before submitting:


1. Consider any line starting with '_' as seperator between the inputs.
2. Print the seperator also along with the grid.
3. The walls of the grid can be represented using any alphabet (any character as a matter of fact)

Friday, October 8, 2010