论坛首页 招聘求职版 面试秘籍

昨天的JAVA面试题,感觉挺难大家帮忙看看!

浏览 6906 次
精华帖 (0) :: 良好帖 (0) :: 隐藏帖 (0)
作者 正文
时间:2008-04-30
import java.io.*;
public class Main {


String str[]=new String[10];


/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

long begin=System.currentTimeMillis();
System.out.println("请输入你的号码:");
try
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String ss=br.readLine();
if(contains(ss,'0'))
{

}
else if(contains(ss,'1'))
{

}
else
{

Test a=new Test();
Stack s=new Stack();

a.Perm(s, ss, 0);

}
long end=System.currentTimeMillis();
long t=end-begin;
System.out.println("本次使用的时间是: "+t);
}
catch(Exception e)
{
System.out.println(" 00000 "+e.getMessage());
}
}

public static boolean contains(String s,char k)
{
for(int i=0;i<s.length();i++)
{
if(s.charAt(i)==k)
return true;
}
return false;
}




}
   
0 请登录后投票
时间:2008-05-05

//2.2 求解:有一个文本文件,记录了某个学校所有人的姓名、出生日期(假设没有人重名,该校大约有2万人)。

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;

public class Test1 {
 public static void main(String[] args) {
  //
  int[][] date = new int[12][31];
  int max = 0;
  int month = 0;
  int day = 0;
  int length = 0;
  
  // read file
  try {
   String file = new String("d:\\test\\test.txt");
   BufferedReader bufferedReader =
    new BufferedReader(new InputStreamReader(new FileInputStream(file)));
   String line = bufferedReader.readLine();
   while (line != null) {
    length = line.length();
    month = Integer.parseInt(line.substring(length - 4, length - 2));
    day = Integer.parseInt(line.substring(length - 2, length - 0));
    date[month - 1][day - 1]++;
    line = bufferedReader.readLine();
   }
  } catch (Exception e) {
  }

  // display
  for (int i = 0; i < date.length; i++) {
   for (int j = 0; j < date[i].length; j++) {
    if (date[i][j] > max) {
     max = date[i][j];
     month = i + 1;
     day = j + 1;
    }
   }
  }
  System.out.println("最多人的日期是:" + month + "月" + day + "日");
 }
}

   
0 请登录后投票
论坛首页 招聘求职版 面试秘籍

跳转论坛:
JavaEye推荐
    快速回复 引用上一条消息 (Alt+S)