百度编程题[倒计时+字典序]
倒计时:100%
function addZero(value){ if(value>=10){ return value; } return '0'+value; } function second( second_time ){ var data = { second : 0, min : 0, hour : 0, day : 0 }; data.second = parseInt(second_time); if( parseInt(second_time )>= 60){ var second = parseInt(second_time) % 60; var min = parseInt(second_time / 60); data.second = second; data.min = min; if( min >= 60 ){ min = parseInt(second_time / 60) % 60; var hour = parseInt( parseInt(second_time / 60) /60 ); data.min = min; data.hour = hour; if( hour >= 24 ){ hour = parseInt( parseInt(second_time / 60) /60 ) % 24; var day = parseInt( parseInt( parseInt(second_time / 60) /60 ) / 24 ); data.hour = hour; data.day = day; } } } return data; } function render(data){ var ele = document.getElementById('jsCountdown'); if(data.day){ ele.children[0] = addZero(data.day)+'天'; }else{ ele.children[0].className = 'hide'; } ele.children[1] = addZero(data.hour)+':'; ele.children[2] = addZero(data.min) + ':'; ele.children[3] = addZero(data.second); }
字典序:100%
var firstStr=readline(); var secondStr=readline(); var firstArr=firstStr.split(''); var secondArr=secondStr.split(''); secondArr.sort(); secondArr.reverse(); for(var i=0;i<secondArr.length;i++){ for(var x=0;x<firstArr.length;x++){ if(secondArr[i]>firstArr[x]){ firstArr[x]=secondArr[i]; secondArr.splice(i,1); } } } print (firstArr.join(''));