-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #344 from azstaylorswift13/master
第十一次作业
- Loading branch information
Showing
6 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* @param {number[]} nums | ||
* @param {number} target | ||
* @return {number[]} | ||
*/ | ||
var twoSum = function(nums, target) { | ||
for(i=0;i<nums.length;i++) | ||
{ | ||
for(j=i+1;j<nums.length;j++) | ||
if(target==nums[i]+nums[j]){ | ||
return [i,j]; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* @param {number} x | ||
* @return {number} | ||
*/ | ||
var reverse = function(x) { | ||
var result = 0; | ||
if(x < -2147483648 || x > 2147483647){ | ||
return 0; | ||
} | ||
else{ | ||
do{ | ||
result = result * 10 + x % 10; | ||
x = parseInt(x / 10); | ||
if(x==0){ | ||
break; | ||
} | ||
} | ||
while(true); | ||
if(result < -2147483648 || result > 2147483647){ | ||
result = 0; | ||
} | ||
return result; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* @param {number} x | ||
* @return {boolean} | ||
*/ | ||
var isPalindrome = function(x) { | ||
var result = 0; | ||
var xcopy = x; | ||
if(x < 0 || x > 2147483647){ | ||
return false; | ||
} | ||
else{ | ||
do{ | ||
result = result * 10 + x % 10; | ||
x = parseInt(x / 10); | ||
if(x==0){ | ||
break; | ||
} | ||
} | ||
while(true); | ||
if(result > 2147483647 || result != xcopy){ | ||
return false; | ||
} | ||
else{ | ||
return true; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>ShopCard</title> | ||
<style> | ||
#in,#out{ | ||
width: 200px; | ||
height: 30px; | ||
} | ||
#in,#out{ | ||
font-size: 18px; | ||
} | ||
#out{ | ||
font-size: 15px; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="psw"> | ||
<label for="">Input:</label> | ||
<input type="text" autofocus value='3efu8-rt67f-e42op-8rpol' id='in'> | ||
<br> | ||
<label for="">Output:</label> | ||
<input type="text" value='' id='out'> | ||
<br> | ||
<button onclick=activative()>激活</button> | ||
</div> | ||
<script> | ||
function activative() { | ||
var In = document.querySelector('#psw #in'); | ||
var Out = document.querySelector('#psw #out'); | ||
var inPassWord = In.value; | ||
var str1 = inPassWord.replace(/-/g, ""); | ||
var strExp = /^[A-Za-z0-9]+$/; | ||
if (strExp.test(str1) && str1.length == 20) { | ||
Out.value = str1.toUpperCase(); | ||
} else { | ||
//In.value = ""; | ||
Out.value = ""; | ||
alert('异常:无效的激活码格式!请重新输入。'); | ||
In.focus(); | ||
} | ||
} | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
function get(s) { | ||
var sta = s.split(","); | ||
for (var i = 0; i < sta.length; i++) { | ||
for (var j = i + 1; j < sta.length; j++) { | ||
if (sta[i] == sta[j]) sta.splice(j, 1); | ||
} | ||
} | ||
return sta.join(","); | ||
} | ||
alert(get("游泳,健身,篮球,游泳,篮球,阅读")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function Countdown() { | ||
var nowTime = new Date(); //获得当前时间对象 | ||
var Data = ['2018/04/04', '2018/04/11', '2018/04/18', '2018/04/25']; | ||
var countDown =[]; | ||
for (var i = 0; i < Data.length; i++) { | ||
var fuTime = new Date(Data[i] + ' ' + '10:00:00'); | ||
var diff_time = fuTime.getTime() - nowTime.getTime(); //获得当前时间距离未来时间的时间差(毫秒 | ||
var D = parseInt(diff_time / (24 * 60 * 60 * 1000)); //计算还剩多少天 | ||
countDown[i] = { | ||
data: Data[i], | ||
daysBefore: D | ||
}; | ||
} | ||
return countDown; | ||
}; | ||
Countdown(); |