- 相关推荐
富士康Java开发面试题目
int leapyear(int y) //计算润年
{
if(y%4==0 && y%100!=0 || y!=100 && y%400==0) return 1;
else return 0;
}
int day_calculate(int y,int m)
{
int day[12]={31,0,31,30,31,30,31,31,30,31,30,31};
day[1]=28+leapyear(y);
return day[m-1]; //计算指定年份和月份的天数
}
int dow(int y,int m) //计算指定月份的1号为星期几
{
int y1=1900,m1=1,d1=1;
long days=1;
while(y1!=y||m1!=m)
{
days++;
d1++;
if(d1>day_calculate(y1,m1)) {m1++;d1=1;}
if(m1>12) {y1++;m1=1;}
}
return days%7;
}
给定字符串,找出出现次数最多的字符,并且计算次数。
public class Stats {
public static void main(String[] args) {
String s = “1456drtgsegsdfgjygjtyujytuytutyur34324343fgy”;
StringBuffer sb = new StringBuffer(s);
bubbleSort(sb);
char maxChar, prevChar, currChar;
maxChar = prevChar = currChar = sb.charAt(0);
int maxCount = 0,currCount = 0;
for (int i = 0; i < sb.length(); i++) {
currChar = sb.charAt(i);
if (currChar == prevChar) {
currCount++;
} else {
if (currCount > maxCount) {
maxCount = currCount;
maxChar = prevChar;
}
currCount = 1;
prevChar = currChar;
}
}
if (currCount > maxCount) {
maxCount = currCount;
maxChar = currChar;
}
System.out.println(maxChar);
System.out.println(maxCount);
}
public static void bubbleSort(StringBuffer data) {
boolean exchanged = true;
for (int j = data.length() – 1; j > 0; j–) {
if (!exchanged) {
break;
}
exchanged = false;
for (int i = 0; i < j; i++) {
if (data.charAt(i) > data.charAt(i + 1)) {
char temp = data.charAt(i);
data.setCharAt(i, data.charAt(i+1));
data.setCharAt(i+1, temp);
exchanged = true;
}
}
}
}
}
Java怎样调用C++(用到C++中的哪些方面)。
java中的方法声明为native。c++做成动态链接库。
【富士康Java开发面试题目】相关文章:
Java认证经典面试题目03-31
中兴2013年Java开发笔试题目及答案02-10
Java开发web的几种开发模式12-13
博惠思华Java开发工程师笔试题目及答案02-10
java开发实习总结04-23
Java开发实习目的04-18
java开发简历模板05-19
java笔试题目及答案02-16
分享:富士康笔试题目11-06