javascript特效实例
java栈编程题_java编程题
第⼀题:输⼊字符串长度len1,字符串s1,字符串长度len2,字符串s2。从后向前⽐较,以最短字符串为标准,输出不同的元素的个数。例如:  输⼊:s1="1,3,5"  len1=3        s2="2,4,1,7,5"  len2=5
输出:1
函数原型
html漂亮表格模板public int getDiffNum(int len1, String s1, int len2, String s2)
[java] :
public class HuaWeiTest {
public static void main(String[] args) {
String s1 = "1,3,5";
String s2 = "2,4,1,7,5";
int len1 = 3;
int len2 = 5;
HuaWeiTest hwt = new HuaWeiTest();
System.out.DiffNum(len1, s1, len2, s2));
}
public int getDiffNum(int len1, String s1, int len2, String s2)  {
int count = 0;
int len = 0;
String[] arr1 = s1.split(",");
String[] arr2 = s2.split(",");
if(len1 > len2) len = len2;
else len = len1;
for(int i=0;i
if(!arr1[len1-i-1].equals(arr2[len2-i-1])) {
count ++;
}
}
return count;
}
}
public class HuaWeiTest {
public static void main(String[] args) {
String s1 = "1,3,5";
String s2 = "2,4,1,7,5";
java经典上机编程题
int len1 = 3;
int len2 = 5;
HuaWeiTest hwt = new HuaWeiTest();
System.out.DiffNum(len1, s1, len2, s2));
}
public int getDiffNum(int len1, String s1, int len2, String s2)  {
int count = 0;
int len = 0;
String[] arr1 = s1.split(",");
String[] arr2 = s2.split(",");
if(len1 > len2) len = len2;
else len = len1;
for(int i=0;i
if(!arr1[len1-i-1].equals(arr2[len2-i-1])) {
count ++;
}
}
return count;
}
}
第⼆题:输⼊字符串长度,字符串,计数m。从前往后计数,当数到m个元素时,m个元素出列,同时
将该元素赋值给m,然后从下⼀个数计数循环,直到所有数字都出列,给定的数全部为⼤于0的数字。输出出队队列。
例如:输⼊:len=4    str="3,1,2,4"  m=7
输出:2,3,1,4
函数原型
public String getOutString(int len, String str, int m)
[java] :
import java.util.ArrayList;
import java.util.List;
public class HuaWeiTest {
public static void main(String[] args) {
int len=4;
String str="3,1,2,4";
HuaWeiTest hwt = new HuaWeiTest();
System.out.OutString(len, str, m));
}
public String getOutString(int len, String str, int m) { String ret ="";
String[] arr = str.split(",");
List ls = new ArrayList();
for(int i=0;i
ls.add(arr[i]);
}
for(int i=0;i
int temp = (m-1)%ls.size();
ret += ls.get(temp);
m = Integer.(temp))+temp;
}
return ret;
}
}
import java.util.ArrayList;
import java.util.List;
public class HuaWeiTest {
public static void main(String[] args) {
int len=4;
String str="3,1,2,4";
14种微量元素背诵口诀
int m=7;
HuaWeiTest hwt = new HuaWeiTest();
System.out.OutString(len, str, m));
}
public String getOutString(int len, String str, int m) { String ret ="";
String[] arr = str.split(",");
List ls = new ArrayList();
ls.add(arr[i]);
}
for(int i=0;i
int temp = (m-1)%ls.size();
ret += ls.get(temp);
m = Integer.(temp))+temp;
}
return ret;
}
}
⼀.选秀节⽬打分,分为专家评委和⼤众评委,score[]数组⾥⾯存储每个评委打的分数,judge_type[]
⾥存储与score[]数组对应的评委类别,judge_type[i] == 1,表⽰专家 评委,judge_type[i] == 2,表⽰⼤众评委,n表⽰评委总数。打分规则如下:专家评委和⼤众评委的分数先分别取⼀个平均分(平均分取整),然后,总分=专家评委平均分* 0.6 +⼤众评委* 0.4,总分取整。如果没有⼤众评委,则 总分=专家评委平均分,总分取整。函数最终返回选⼿得分。
函数接⼝int cal_score(int score[], int judge_type[], int n)
[java] :
public class SWTest {
public static void main(String[] args) {
int score[] = {
34,53,65,75,64
};
int judge_type[] = {
1,1,1,2,2
};
SWTest st = new SWTest();
System.out.print(st.cal_score(score, judge_type, 5));
}
int cal_score(int score[], int judge_type[], int n){
int totalExpert = 0;
int totalPublic = 0;
int numExpert = 0;
int numPublic = 0;
for(int i=0;i
if(judge_type[i]==1) {
totalExpert += score[i];
numExpert ++;
}
if(judge_type[i] == 2){
totalPublic += score[i];
numPublic ++;
}
}
if(0==numPublic){
return (int)totalExpert/numExpert;
学习php必备软件
excel整列公式自动计算}else
{
return (int)((totalExpert/numExpert)*0.6) +
(int)((totalPublic/numPublic)*0.4);
}
}
}
public class SWTest {
public static void main(String[] args) {
int score[] = {
34,53,65,75,64
};
int judge_type[] = {
1,1,1,2,2
};
SWTest st = new SWTest();
System.out.print(st.cal_score(score, judge_type, 5)); }
int cal_score(int score[], int judge_type[], int n){
int totalExpert = 0;
int totalPublic = 0;
int numExpert = 0;
int numPublic = 0;

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。