- 相關(guān)推薦
富士康Java開發(fā)面試題目
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]; //計算指定年份和月份的天數(shù)
}
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;
}
給定字符串,找出出現(xiàn)次數(shù)最多的字符,并且計算次數(shù)。
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怎樣調(diào)用C++(用到C++中的哪些方面)。
java中的方法聲明為native。c++做成動態(tài)鏈接庫。
【富士康Java開發(fā)面試題目】相關(guān)文章:
Java開發(fā)實習(xí)目的04-18
java開發(fā)簡歷模板05-19
java筆試題目及答案02-16
分享:富士康筆試題目11-06