java实现最大权重单增序列import java.util.Scanner;
public class Main {
public static int data[] = null;
public static int weight[] = null;
public static int res[] = null;
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
System.out.println("输入序列个数java权重代码:");
int n = 0;
n = scan.nextInt();
System.out.println("输入" n "个数(空格隔开):");
data = https://www.04ip.com/post/new int[n];
for (int i = 0; in;i) {
data[i] = scan.nextInt();
}
System.out.println("输入" n "个数java权重代码的权重(空格隔开):");
weight = new int[n];
for (int i = 0; in;i) {
weight[i] = scan.nextInt();
}
doit(n);
int max = res[0];
int k = 0;
for (int i = 1; in;i) {
if (maxres[i]) {
max = res[i];
k = i;
}
}
System.out.println("最大权值:" max);
System.out.println("序列为:");
print(k);
System.out.println();
}
public static void doit(int n) {
res = new int[n];
for (int i = 0; in;i) {
res[i] = weight[i];
for (int j = 0; ji;j) {
if (data[i]data[j]res[i]weight[i] res[j]) {
res[i] = weight[i] res[j];
}
}
}
}
public static void print(int k) {
for (int i = k-1; i = 0; --i) {
if (res[i] weight[k] == res[k]) {
print(i);
}
}
System.out.print(" " data[k]);
}
}
输入样例:
输入序列个数:
5
输入5个数(空格隔开):
1 4 2 3 9
输入5个数java权重代码的权重(空格隔开):
1 10 1 1 1
输出样例
最大权值:12
序列为:
1 4 9
注:序列可能不唯一java权重代码,就输出java权重代码了一组
java的权重匹配算法技术求教网站权重其实是指百度
而百度权重就是指网站获取流量java权重代码的能力.根据java权重代码你网站获取流量的能力来划分权重等级.下面给出的就根据流量的多少来划分权重的数据.
百度预计流量1~99 权重1
百度预计流量100~499 权重2
百度预计流量500~999 权重3
百度预计流量1000~4999 权重4
百度预计流量5000~9999 权重5
百度预计流量10000~49999 权重6
百度预计流量50000~199999 权重7
百度预计流量200000~999999 权重8
百度预计流量1000000以上 权重9”
另外要说的 就是百度权重是第三方根据研究百度的出来的结论.百度自身是没有这个说法的.
如何在java代码中设置权重editText.setLayoutParams(new LinearLayout.LayoutParams(width, height, weight)); 只有LinearLayout才有layout_weight属性 。
用java写了一个最小生成树问题的程序 , 在进行快速排序边长的权重时,出现了下面的报错说明 edges[] edgelist1= g.listedges(graph1);中的listedges方法有问题
class graph {
public double[][] generate(int n) {
return null;
}
public double[] listlength(double[][] d) {
return null;
}
public edges[] listedges(double [][] d) {
return null;
}
}
全返回null的 , , , , ,,,,,都还没做
设计一种java数据结构,按照权重进行排序public enum SortBy {
Number,
Weights1,
Weights2
}
import java.util.Comparator;
public class MyComparator implements ComparatorStudent{
private SortBy sortBy;
public MyComparator (SortBy sortBy){
this.sortBy = sortBy;
}
@Override
public int compare(Student s1, Student s2) {
switch (this.sortBy) {
case Weights1:
return s1.getWeights1() - s2.getWeights1();
case Weights2:
return s1.getWeights2() - s2.getWeights2();
default:
return s1.getNumber() - s2.getNumber();
}
}
}
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
public class Student {
private int number;
private int weights1;
private int weights2;
public Student(int number, int weights1, int weights2) {
this.number = number;
this.weights1 = weights1;
this.weights2 = weights2;
}
public int getNumber() {
return this.number;
}
public int getWeights1() {
return this.weights1;
}
public int getWeights2() {
return this.weights2;
}
public static void main(String[] args){
final Student s1 = new Student(1, 20, 300);
final Student s2 = new Student(2, 10, 100);
final Student s3 = new Student(3, 30, 200);
final ListStudent array = new LinkedListStudent();
array.add(s1);
array.add(s2);
array.add(s3);
final ComparatorStudent numberComparator = new MyComparator(SortBy.Number);
【java权重代码 java 权重】Collections.sort(array, numberComparator);
System.out.println("sort by number");
System.out.print("Number: ");
for(Student s: array){
System.out.print(s.getNumber()" ");
}
System.out.println("\n\n");
final ComparatorStudent weights1Comparator1 = new MyComparator(SortBy.Weights1);
System.out.println("sort by weights1");
System.out.print("Number: ");
Collections.sort(array, weights1Comparator1);
for(Student s: array){
System.out.print(s.getNumber()" ");
}
System.out.println("\n\n");
final ComparatorStudent weights2Comparator = new MyComparator(SortBy.Weights2);
System.out.println("sort by weights2");
System.out.print("Number: ");
Collections.sort(array, weights2Comparator);
for(Student s: array){
System.out.print(s.getNumber()" ");
}
System.out.println("\n\n");
}
}
sort by number
Number: 1 2 3
sort by weights1
Number: 2 1 3
sort by weights2
Number: 2 3 1
关于java权重代码和java 权重的介绍到此就结束了 , 不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。
推荐阅读
- cmongodb多表更新数据类型,数据库多表更新
- 手机主板清洗胶水怎么清洗,手机主板用什么清洗剂
- 快手直播如何用猫咪,怎么在快手直播间猫粮怎么设置
- mysql怎么加外键 mysql 添加外键
- 联想gf405显卡怎么样,联想g40显卡是多少
- 棋牌软件竖屏游戏,所有开源横屏棋牌网址大全
- 如何取消word分节符,如何取消word分节符显示
- linux启动时运行命令 linux 启动执行命令
- 电脑qq怎么打印简历,电脑怎么打印资料