Last active
August 29, 2015 14:04
-
-
Save jikeytang/454cbb566e69e3b9c061 to your computer and use it in GitHub Desktop.
[ Javascript ] - 20140728-题目1
This file contains hidden or 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
琴琴是一个具备高情商与高智商"双重杀手",她想根据注册时间较早车牌的的车, | |
来陪她一块去海边看日出。经过研究发现,车牌也是按序列发放, | |
由5个字母或数字组成,每个位排序是按字母数字的ASCII的先后位置, | |
比如:0o4r4 > ye6er ,0的ASCII是48,y的ASCII是121。所以0o4r4是较早的, | |
如果第一位相同,则判断第2位。实现这个程序。 | |
PS: | |
1. 回复时注意加上下面这句话,才会有语法高亮或格式缩进。 | |
```javascript | |
// you code | |
``` | |
2. 粘贴代码时请使用shift+tab,缩进前面的空白。 |
var str1="0o4r4";
var str2="ye6er";
function compareMin(str1,str2){
var flag=true;
for(var i=0,ii=str1.length;i<ii;i++){
if(str1.charCodeAt(i)>str2.charCodeAt(i)){
flag=false;
return (str1+"比"+str2+"要晚");
}else if(str1.charCodeAt(i)<str2.charCodeAt(i)){
flag=false;
return (str1+"比"+str2+"要早");
}
};
if(flag){
return "一样的";
}
};
compareMin(str1,str2);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@feng524822 好吧。。。