JavaScript-3.1--获取用户的输入,输出用户输入的两数之和---ShinePans

提示用户输入两个数,然后输出用户输入的两数之和

第一次输入 ,输入处为空

第二个输入,输入处为默认27  (这里强调语句的使用)

<html>
	<head>
		<meta http-equiv="content-type" content="text/html;charset=GB2312"/>
		<title> 3.1 让用户输入两个数字,然后输出相加的结果 </title>
	</head>
	<body style="overflow:auto;padding:0px;margin:0px;">
		<div style="font-size:14px;font-weight:bold;color:white;font-family:Arial,宋体;background-color:#6090DA;padding:4px 10px;">
			<script>
				intA=prompt("请输入第一个数字","");  //这里初始没有显示
				intB=prompt("请输入第二个数字",27);  //这里初始会显示27
				document.write("你输入的第一个数字是"+intA);
				document.write("你输入的第二个数字是"+intB);
				document.write("<br>两者和是"+(parseInt(intA)+parseInt(intB) ));
				</script>
			</div>
		</body>
</html>

打开效果:

JavaScript-3.1--获取用户的输入,输出用户输入的两数之和---ShinePans,布布扣,bubuko.com

时间: 2024-08-06 03:43:15

JavaScript-3.1--获取用户的输入,输出用户输入的两数之和---ShinePans的相关文章

LeetCode167 两数之和 II - 输入有序数组

给定一个已按照升序排列 的有序数组,找到两个数使得它们相加之和等于目标数. 函数应该返回这两个下标值 index1 和 index2,其中 index1 必须小于 index2. 说明: 返回的下标值(index1 和 index2)不是从零开始的. 你可以假设每个输入只对应唯一的答案,而且你不可以重复使用相同的元素. 示例: 输入: numbers = [2, 7, 11, 15], target = 9 输出: [1,2] 解释: 2 与 7 之和等于目标数 9 .因此 index1 = 1

【Leetcode】【简单】【1. 两数之和】【JavaScript】

题目描述 1. 两数之和 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标. 你可以假设每种输入只会对应一个答案.但是,你不能重复利用这个数组中同样的元素. 示例: 给定 nums = [2, 7, 11, 15], target = 9 因为 nums[0] + nums[1] = 2 + 7 = 9所以返回 [0, 1] 来源:力扣(LeetCode)链接:https://leetcode-cn.com/problem

20150908 3、输入整数a和b,若a2+b2大于100,则输出a2+b2百位以上数字,否则输出两数之和。

167 Two Sum II - Input array is sorted 两数之和 II - 输入有序数组

给定一个已按照升序排列 的有序数组,找到两个数使得它们相加之和等于目标数.函数应该返回这两个下标值 index1 和 index2,其中 index1 必须小于 index2.请注意,返回的下标值(index1 和 index2)不是从零开始的.你可以假设每个输入都只有一个解决方案,而且你不会重复使用相同的元素.输入:数组 = {2, 7, 11, 15}, 目标数 = 9输出:index1 = 1, index2 = 2详见:https://leetcode.com/problems/two-

167. 两数之和 II - 输入有序数组

Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, where index1 m

Leetcode之二分法专题-167. 两数之和 II - 输入有序数组(Two Sum II - Input array is sorted)

给定一个已按照升序排列 的有序数组,找到两个数使得它们相加之和等于目标数. 函数应该返回这两个下标值 index1 和 index2,其中 index1 必须小于 index2. 说明: 返回的下标值(index1 和 index2)不是从零开始的. 你可以假设每个输入只对应唯一的答案,而且你不可以重复使用相同的元素. 示例: 输入: numbers = [2, 7, 11, 15], target = 9 输出: [1,2] 解释: 2 与 7 之和等于目标数 9 .因此 index1 = 1

两数之和 II - 输入有序数组 --二分查找

题目 给定一个已按照升序排列的有序数组,找到两个数使得它们相加之和等于目标数. 函数应该返回这两个下标值 index1 和 index2,其中 index1 必须小于 index2. 说明: 返回的下标值(index1 和 index2)不是从零开始的. 你可以假设每个输入只对应唯一的答案,而且你不可以重复使用相同的元素. 示例: 输入: numbers = [2, 7, 11, 15], target = 9 输出: [1,2] 解释: 2 与 7 之和等于目标数 9 .因此 index1 =

[LeetCode] Two Sum II - Input array is sorted 两数之和之二 - 输入数组有序

Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, where index1 mu

[LeetCode] Two Sum IV - Input is a BST 两数之和之四 - 输入是二叉搜索树

Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target. Example 1: Input: 5 / 3 6 / \ 2 4 7 Target = 9 Output: True Example 2: Input: 5 / 3 6 / \ 2 4 7 Targe