AceTheInterview
Jobs in Pune | Work better in teams | Socialize with friends | Submit Q&A | Tell a friend
Search site for 

Top 100 Interview Questions & Answers in a convenient and easy to read book!

“I bought this guide a few days ago to prepare for my interview with Oracle. Many of the questions they asked me were from this guide. I found this book absolutely great!”

– Ravi, California

Read more comments...

Interview Questions And Answers RSS Feed

Answers »

  1. Submitted By: Suvitha Balu — February 4, 2008
    +2 votes
      + -

    #include
    #include
    #define MAXR 14
    #define MAXC 20
    int main(int argc,char *argv[])
    {
    FILE *fp;
    int xcount=0,ycount=0,i,j;
    int sx,sy,t;
    char str[MAXC],ch,*ptr;
    char a[MAXR][MAXC] ;

    if (argc != 2)
    {
    printf(”Argument shuold be two only\n”);
    return 0;
    }

    fp = fopen ( argv[1],”r”);
    if ( fp == NULL )
    {
    printf(”can’t open the input file\n”);
    return 0;
    }
    for (i = 0; i:%s:Acrosss\n”,sx+1,sy+1,str);
    }
    }
    xcount++;

    for(i=0;i 0)
    if (a[j-1][i] != ‘0′) continue;

    sx = j;
    sy = i;
    t=0;
    while( a[j][i] != ‘0′ && j :%s:Down\n”,sx+1,sy+1,str);
    }
    }
    ycount ++ ;
    }
    return 0;
    }

  2. Submitted By: Oceans Eleven — February 7, 2008
    +1 votes
      + -

    //TODO: reading from file instead of dummy data in code
    #include “stdafx.h”
    #include “stdio.h”
    #include “stdlib.h”
    #include “string.h”

    #define ROWS 14
    #define COLS 22

    char *cross[ROWS];
    int processrow[ROWS][COLS];
    int processcol[ROWS][COLS];

    int processcw()
    {
    int i,j;
    int jnew;
    int inew;

    for(i=0;iAcross\t”,i+1,j+1);
    jnew=j;
    while( jnewDown\t”,i+1,j+1);
    inew=i;
    while( inew

  3. Submitted By: Anand — February 20, 2008
    +1 votes
      + -

    The solution to this is as follows.
    1. Create a matrix class
    2. Have a single function that returns all words horizontally
    3. First call this function
    4. Transpose the matrix
    5. Call the function again.

    Here is the full Python code.

    “”" Read a crossword like grid and print the
    words in it “”"

    class Grid(object):

    def __init__(self):
    self.data=[]

    def __str__(self):

    rows = [”.join(row) for row in self.data]
    return ‘\n’.join(rows)

    def read(self, gridfile):

    # Read data line by line
    for line in open(gridfile):
    line = line.strip()
    row = []
    # Read char by char and add it to
    # the row if it is an alphabet, if
    # not, add a null char
    for c in line:
    if (c>=’a’ and c=’A’ and c=len(row):break

    if len(word)>=2:
    if invert:
    words.append((col, rowcnt, word))
    else:
    words.append((rowcnt, col, word))

    word = ”
    idx += 1

    rowcnt += 1

    return words

    def _transpose(self, lists, defval=’ ‘):
    return map(lambda *row: [elem or defval for elem in row], *lists)

    def transpose(self):
    self.data = self._transpose(self.data)

    def getWords(self):
    print ‘Across=>’,self.across()
    # Now transpose
    self.transpose()
    print ‘Down=>’,self.across(True)

    if __name__==”__main__”:
    g = Grid()
    g.read(’grid.txt’)
    print g
    g.getWords()

  4. Submitted By: Rekha — February 21, 2008
    +1 votes
      + -

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;

    namespace ConsoleApplication3
    {
    public class Program
    {
    public static void Main(string[] args)
    {
    string myString = string.Empty;
    using (StreamReader myFile = new System.IO.StreamReader(”input.txt”))
    {
    int lineCount = 1;
    string startingpoint = string.Empty, oldStartingPoint=string.Empty;
    string[] eachLine = new string[30];
    myString = myFile.ReadLine();
    eachLine[lineCount - 1] = myString;
    #region this is for across
    while (myString !=null)
    {
    char[] achar = myString.ToCharArray();
    for (int i = 0; i “;
    if (startingpoint != oldStartingPoint)
    {
    Console.WriteLine(startingpoint);
    }
    oldStartingPoint = startingpoint;
    while (i 0)
    {
    for (int a = 0; a “;
    for (int i = row + 3; i

  5. Submitted By: Mathew K.A — May 2, 2008
    not yet rated
      + -

    #include
    #include

    int main()
    {
    int r=0,c=0,i=0,k=0;
    char temp[20];
    char arr[15][20]={”00000CONGRESS0000000″,”000I0000000U00000L00″,”000M0000000PRESIDENT”,”000P0000000R00I00G0H”,”INDEPENDENCE00X00I0E”,”000A0000000M00000S0R”,”0VICEPRESIDENT000L0E”,”000H0000000C00TRIAL0″,”0E0M0S00000O00000T00″,”NINETEEN0FOUR000FIVE”,”0G0N0N00000R000L0V00″,”0H0T0A00000TWO0AMEND”,”0T00STATE000000W0000″,”00000E000000000S0000″};

    for(r=0;r 2)
    {
    temp[i]=”;
    printf(”:%s:Across\n”,r+1,k,temp);
    }
    if( i != 0)
    {
    i=0;
    temp[i]=”;
    }
    }
    }
    }

    for(c=0;c 2)
    {
    temp[i]=”;
    printf(”:%s:Down\n”,k,c+1,temp);
    }
    if( i != 0)
    {
    i=0;
    temp[i]=”;
    }
    }
    }
    }

    }

  6. Leave an Answer/Comment

    To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
    Click to hear an audio file of the anti-spam word

Our Sponsors
Our Sponsors
Contact Us | FAQ | Sitemap | Terms of Use | Privacy Policy | Tell a Friend

Copyright © 1999-2006 Jeeve Technologies LLC. All rights reserved.