(抱歉我的英文= /) 这是伪的:
function lnko(a, b)
-if a = b then lnko := a
-if a < b then lnko := lnko(a, b-a)
-if a > b then lnko := lnko(a-b, b)
function end
Run Code Online (Sandbox Code Playgroud)
我的代码是:
<html>
<head>
<script type="text/javascript">
function run()
{
var a = document.getElementById("a").value;
var b = document.getElementById("b").value;
var s = lnko(a,b)
document.write(a+"/"+b+"<br>"+(a/s)+"/"+(b/s));
// document.write("<br>"+s)
}
function lnko(a,b)
{
alert(a+"..."+b)
if (a==b)
{
return a;
}
if (a<b)
{
return lnko(a,(b-a));
}
if (a>b)
{
return lnko((a-b),b);
} …Run Code Online (Sandbox Code Playgroud) 我有一个数组,我需要使用每个项目,但是forEach和$ .each在这里不适合数组(jsfiddle)
var person = new Array();
person["firstName"] = "John";
person["lastName"] = "Doe";
person["age"] = 46;
jQuery.each(person, function(index, item) {
alert(index + " : " + item);
});
Run Code Online (Sandbox Code Playgroud) import javax.swing.*;
import java.util.Random;
import java.util.Scanner;
class Fifie
{
public static void main (String [] args)
{
String Iplay;//A ke rock, B ke skere, c is paper
String PCplay;
int value;
Scanner scan = new Scanner(System.in);
Random num = new Random();
Iplay = JOptionPane.showMessageDialog("Enter R for rock, P for paper and S for scissors");
Iplay = scan.next();
Iplay = Iplay.toUpperCase();
PCplay = num.nextInt(3);
switch (value);
{
case 0:
{
PCplay = "R";
break;
}
case 1:
{
PCplay = "P"; …Run Code Online (Sandbox Code Playgroud) 我使用此函数来验证一个输入元素:
function validerInput(qte, qtemax) {
var floatRegex = /^((\d+(\.\d *)?)|((\d*\.)?\d+))$/;
if (floatRegex.test(qte.value)) {
var a = qte.value;
var b = qtemax;
if (a > b) {
alert('if qtemax : ' + qtemax + ', qte : ' + qte.value);
qte.value = '';
}
else {
alert('else qtemax : ' + qtemax + ', qte : ' + qte.value);
}
}
else {
qte.value = '';
}
}
Run Code Online (Sandbox Code Playgroud)
但问题始终是启动其他人的警报,第一个从来不知道问题
你有什么主意吗 :
启动的警报包含例如234和5.66
我想制作按钮,它将选择我的 p 标签中的所有文本。标签示例:
<p class="foo">
some text
<div>this div is child of p</div>
<div>one more row</div>
</p>
Run Code Online (Sandbox Code Playgroud)
解决方案也必须通过 window.getSelection() 或类似但不是 jQuery。我试图通过使用 selectNodeContents(el) 来做到这一点,但结果只是第一行。
任何人都可以帮助我,因为我无法弄清楚这一点。
编辑代码:
var selection = window.getSelection();
var txt = document.getElementsByClassName("foo");
var range = document.createRange();
range.selectNodeContents(txt);
selection.removeAllRanges();
selection.addRange(range);
Run Code Online (Sandbox Code Playgroud) 我收到错误:非法开始表达,不知道如何解决这个问题.这是我需要用指南编写的程序的所有声明.该计划旨在计算船的成本.提前致谢!
import java.util.Scanner;
public class boat
{
public static void main(String[] args)
{
//declarations
....
double depreciationYear1 = bookValueBeginningYear1 * (2 * 100% / 3);
^
double bookValueBeginningYear2 = bookValueBeginningYear1 - depreciationYear1;
double depreciationYear2 = bookValueBeginningYear2 * (2 * 100% / 3);
^
double bookValueBeginningYear3 = bookValueBeginningYear2 - depreciationYear2;
double depreciationYear3 = bookValueBeginningYear3 * (2 * 100% / 3);
.... ^
double exciseTaxYear1 = 90% * boatPrice/1000 * 25;
^
double exciseTaxYear2 = 80% * boatPrice/1000 * 25;
^
double …Run Code Online (Sandbox Code Playgroud) var a = new String("Hi");
typeof a; // output is "object"
typeof a.constructor // output is String;
Run Code Online (Sandbox Code Playgroud)
但是当我试图检查时 a.constructor==String;// output is true
我认为上面的陈述(a.constructor==String),应该是假的,因为它应该等于"嗨"
javascript ×5
java ×2
jquery ×2
arrays ×1
each ×1
numbers ×1
pseudocode ×1
selection ×1
validation ×1