我知道很多次都会问过这个问题,但到目前为止,以前给出的答案都没有对我有用,这是我的代码:
<html>
<head>
<title>Programa</title>
</head>
<body>
<div>
Introduzca una palabra a buscar:
<input type="text" id="INPUT">
<%@ page import="java.net.URL" %>
<%@ page import="com.google.gson.*" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.InputStream" %>
<%@ page import="java.io.Reader" %>
<%@ page import="javax.swing.*" %>
<%@ page import="java.awt.event.*;" %>
<%!
int min(int a,int b) {
return (a>b)? b:a;
}
int edit_distance(String a,String b) {
int n = a.length(), m = b.length(),costo;
int[][] mat = new int[n+1][m+1];
for(int i=0;i<=n;++i) mat[i][0] = i;
for(int …Run Code Online (Sandbox Code Playgroud) 这是"主"类(不包含主方法)
import javax.swing.*;
import java.awt.*;
//import java.lang.Object;
//import java.awt.event.ActionListener;
//import java.awt.event.;
public class Program {
public JFrame frame;
public JPanel header;
public JPanel text;
public JPanel body;
public JTextField input;
public JButton agregar;
public List listA;
public List listB;
public Program(String title) {
frame = new JFrame(title);
frame.setSize(500,600);
frame.setResizable(false);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(null);
header = new JPanel();
header.setBackground(new Color(255,204,50));
header.setBounds(0,0,500,100);
text = new JPanel();
text.setBackground(new Color(255,204,100));
text.setBounds(0,100,500,50);
text.setLayout(null);
//Inicializando la "entrada"
input = new JTextField(20);
input.setBounds(50,13,300,25);
text.add(input);
agregar = new JButton(); …Run Code Online (Sandbox Code Playgroud) 我想做这样的事情:
int a = 9, b = 3;
map<char,operator> m;
m['+'] = +;
m['-'] = -;
m['*'] = *;
m['/'] = /;
for(map<char,operator>::iterator it = m.begin(); it != m.end(); ++it) {
cout << func(a,b,it -> second) << endl;
}
Run Code Online (Sandbox Code Playgroud)
输出是这样的:
12
6
27
3
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
我尝试编译时遇到一个奇怪的错误:
class CucumberMarket {
public:
bool ans;
int n,cont,K,b;
bool check(const vector<int> &precios,long long price,int pos) {
++cont;
if(cont == K and b < price) ans = false;
if(!ans) return ans;
for(int i = pos + 1; i < n; ++i) {
if(cont < K) ans &= check(precios,price + precios[i],i);
}
--cont;
}
string check(vector <int> price, int budget, int k) {
n = price.size();
K = k;
b = budget;
ans = true;
cont = 0;
for(int i = …Run Code Online (Sandbox Code Playgroud)