我有以下数组列表
cd1 = [3,5,7,10,15,16]
cd2 = [4,10,5,8]
Run Code Online (Sandbox Code Playgroud)
输出
[3,7,15,16]
Run Code Online (Sandbox Code Playgroud)
如您所见,一个有 6 个位置,另一个有 4 个。
那么如果它们重复,它们应该存储在另一个 ArrayList 中
我携带的代码:
import java.util.ArrayList;
public class inexistentes {
public static ArrayList<Integer> inexistentes(ArrayList<Integer> cd1, ArrayList<Integer> cd2){
ArrayList<Integer> newList = new ArrayList<>();
for(int i = 0; i < cd1.size(); i++){
if(cd1.contains(i) ){
newList.add(i);
}
}
return newList;
}
}
Run Code Online (Sandbox Code Playgroud)
我怎么能买到那些链子...
我已经有一个 for 但我不知道如何实现 if。
我正在 vue 中工作,当查看页面时,链接显示如下:
http://localhost:8080/#/
http://localhost:8080/#/categorias
Run Code Online (Sandbox Code Playgroud)
我该如何删除它?
所以它看起来像这样?
http://localhost:8080/categorias
http://localhost:8080/
Run Code Online (Sandbox Code Playgroud)
这是我的 js 路由器
import { createRouter, createWebHashHistory } from 'vue-router'
//import Home from '../views/Home.vue'
import Inicio from '../components/Inicio.vue'
const routes = [
{
path: '/',
name: 'inicio',
component: Inicio
},
{
path: '/about',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
},
{
path: '/categorias',
name: …Run Code Online (Sandbox Code Playgroud) 我必须将字典的键与列表进行比较。
l = {"Carlos": 1131577, "Rodrigo": 3250239, "Marisol": 1174787}
Run Code Online (Sandbox Code Playgroud)
里面的话
d = "Carlos Marisol"
Run Code Online (Sandbox Code Playgroud)
对于字典中出现的字符串中的每个单词,我想将相应的值相加。
输出应该是这样的:
2306364
Carlos Marisol
Run Code Online (Sandbox Code Playgroud)
我制作的代码如下:
l = {"Carlos": 1131577, "Rodrigo": 3250239, "Marisol": 1174787}
d = "Carlos Marisol"
a = d.split(' ')
n = 0
h = ""
f = len(a)
for k, v in l.items():
if k == a[0] or k == a[1]:
n += v
h += k + " "
print(n)
print(h)
Run Code Online (Sandbox Code Playgroud)
输出如下:
2306364
Carlos Marisol
Run Code Online (Sandbox Code Playgroud)
如您所见,它可以工作,但可以这么说是手动的。
if k == a[0] or k …Run Code Online (Sandbox Code Playgroud)