程序员必做50题(16-30)—————— 程序员必做50题(31-45)
for(var i=1;i<=4;i++){
for(var j=1;j<=4;j++){
for(var k=1;k<=4;k++){
if(i!=j && i!=k && j!=k){
console.log(i,j,k)
}
}
}
}
var profit = 1000001;
var bonus = 0;
if(profit>0 && profit<=100000){
bonus = profit*0.1;
}else if(profit>100000 &&profit<=200000){
bonus += 10000+(profit-100000)*0.075;
}else if(profit>200000 && profit<=400000){
bonus += 17500+(profit-200000)*0.05;
}else if(profit>400000 && profit<=600000){
bonus += 27500+(profit-400000)*0.03;
}else if(profit>600000 && profit<=1000000){
bonus += 33500+(profit-600000)*0.015;
}else{
bonus += 39500+(profit-1000000)*0.01;
}
console.log(bonus);
for(var i=1;i<1000;i++){
var a = parseInt(Math.sqrt(i+100));
var b = parseInt(Math.sqrt(i+168));
if(a*a===(i+100) && b*b===(i+168)){
console.log(i);
}
}
var year = 2021,month = 3, day = 25;
var monthDay = [31,28,31,30,31,30,31,31,30,31,30,31];
var days = 0,i = 0;
if((year%4===0 && year%100!==0) || year%400===0){
if(month>2){
days +=1;
}
}
for(;i<month-1;i++){
days += monthDay[i];
}
days += day;
console.log(days);
function sma (a,b,c){
var d,x,micro,middle,big;
if(a<b){
d = b;
x = a;
}else{
d = a;
x = b;
}
if(d < c){
big = c;
micro = x;
middle = d;
}else if(x > c){
big = d;
middle = x;
micro = c;
}else{
big = d;
middle = c;
micro = x;
}
console.log(micro+' '+middle+' '+big)
}
sma(6,2,8);
for(var i=1;i<6;i++){
if(i===1 || i===5){
console.log('* * * * ')
}else{
console.log('*')
}
}
for(var i=1;i<6;i++){
var a = '';
if(i==1 || i==5){
for(var j=1;j<5;j++){
a += '* ';
}
}else{
a='* '
}
console.log(a);
}
var num = 90;
var a = num+'=';
for(var i=2;i<=num;i++){
if(num%i===0){
num/=i;
a+=i+'*'
i=1;
}
}
a = a.slice(0,a.length-1)
console.log(a)
for(var i=1;i<=9;i++){
var sum ='';
for(var j=1;j<=i;j++){
sum+=j+'*'+i+'='+i*j+' '
}
console.log(sum)
}
for(var i=1;i<=8;i++){
var a = '';
for(var j=1;j<=8;j++){
if((i+j)%2===0){
a += '■';
}else{
a += '□';
}
}
console.log(a)
}
function a(x){
var a1 = 1,a2 = 1;
for(var i=3;i<=x;i++){
var c = a1;
a1 = a2;
a2 = c + a1;
}
return a2;
}
var a = 100,b = 200,n = 0,num = 0;
for( a ; a <= b ; a++ ) {
for ( var j = 1; j <= a; j ++) {
if(a % j == 0){
n++;
}
}
if( n == 2){
num++;
console.log(n);
}
}
for(var i=1;i<10;i++){
for(var j=0;j<10;j++){
for(var k=0;k<10;k++){
if((i*i*i)+(j*j*j)+(k*k*k)===(i*100)+(j*10)+k){
console.log(i,j,k);
}
}
}
}
function grade(x){
return x>=90 ? 'A' : (x>=60 ? 'B' : 'C')
}
console.log(grade(88));
function adj(m,n){
var c = 0,w,e;
if(m<n){
c = m;
m = n;
n = c;
}
w = m%n;
e = m*n;
while(w!=0){
m = n;
n = w;
w = m%n;
}
return '最小的公被数是:'+e/n+'最大的公约数是:'+n;
}
console.log(adj(3,5))
function statistics(x){
var script = 0,letter = 0,blank = 0,digit = 0,charset = 0;
for(var i=0;i<x.length;i++){
var a = x.charCodeAt(i)
if(a >= 19986){
script++;
}else if((a >= 65 && a <= 90) || (a >= 97 && a <= 122)){
letter++;
}else if(a >= 48 && a <=57){
blank++;
}else if(a === 32){
digit++;
}else{
charset++;
}
}
return '中文有:'+script+'个 英文有:'+letter+'个 数字有:'+blank+'个 空格有:'+digit+'个 其他字符有:'+charset+'个';
}
console.log(statistics('你好!! HELLO word! 123'))
新手上路,望各位大佬指教-----------
如有相关资料、视屏给作者看看可否?后续的题以后更新-------
[email protected]
欢迎提各种意见------------------------------------------------------------------------------------------------- 学WEB前端的第14天
程序员必做50题(16-30)—————— 程序员必做50题(31-45)