Skip to content

Commit

Permalink
Merge pull request #344 from azstaylorswift13/master
Browse files Browse the repository at this point in the history
第十一次作业
  • Loading branch information
Chunliuliu authored Mar 31, 2018
2 parents e6740e7 + dcebcce commit f6f6b6d
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 0 deletions.
14 changes: 14 additions & 0 deletions 第9组/甘振豪/第十一次作业/leetcode1.js
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];
}
}
};
24 changes: 24 additions & 0 deletions 第9组/甘振豪/第十一次作业/leetcode7.js
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;
}
};
27 changes: 27 additions & 0 deletions 第9组/甘振豪/第十一次作业/leetcode9.js
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;
}
}
};
52 changes: 52 additions & 0 deletions 第9组/甘振豪/第十一次作业/qs1.html
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>&nbsp;&nbsp;&nbsp;
<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>
10 changes: 10 additions & 0 deletions 第9组/甘振豪/第十一次作业/qs2.js
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("游泳,健身,篮球,游泳,篮球,阅读"));
16 changes: 16 additions & 0 deletions 第9组/甘振豪/第十一次作业/qs3.js
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();

0 comments on commit f6f6b6d

Please sign in to comment.