BlackBerry

  www.blackberry.com
Work in HR? Unlock Free Profile

BlackBerry Software Engineer Interview Question

I interviewed in Ottawa, ON (Canada) and was asked:
"How would you draw an "X" on a screen made from smaller "x"s?"
Add Tags [?]
Answer

Part of a Software Engineer Interview Review - one of 383 BlackBerry Interview Reviews

Answers & Comments

1
of 1
vote
generally, use a loop:

char[][] Xs = new char[MAX_ROW][MAX_COL];

for(int row = 0; row < MAX_COL / 2; row++) {
          Xs[row][row] = 'x' ;
          Xs[row][MAX_COL - row] = 'x' ;
}

Xs[MAX_COL / 2][MAX_COL / 2] = 'x' ;

for(int row = MAX_COL / 2 + 1; row < MAX_COL; row++) {
          Xs[row][row] = 'x' ;
          Xs[row][MAX_COL - row] = 'x' ;
}

draw(Xs);
- Anonymous on Feb 1, 2011

To comment on this question, Sign In with Facebook or Sign Up

Tags are like keywords that help categorize interview questions that have something in common.