当前位置:网站首页>Circular exercises of JS

Circular exercises of JS

2022-06-25 12:38:00 Fall in love with*

1. Enter the score five times in a cycle , Sum up   averaging   For maximum   For the minimum .

2. List 1-1000 All odd and even numbers within  

3. Chicken and rabbit in the same cage : in total 100 A foot , How many each ?

4. The output is reversed 99 Multiplication table

5. Output the number of daffodils in all three digits .( Narcissistic number : The third power of a bit + The third power of ten + The third power of a hundred == The number itself )

 Such as :153 = 1*1*1 + 5*5*5 + 3*3*3

6. Cycle through a student 5 And calculate the average score , If a score is entered as negative , Stop entry and prompt for entry errors

7. There is an equation 12()34()56()78()9 = 59, Only add and subtract can be placed in brackets , If you want the equation to hold , So what symbols should be placed in each bracket .

            var sum = 0;
			var avg = 0;
			var max = 0;
			var min;
			var score = 0;
			for (var i = 1; i <= 5; i++) {
				score = Number(prompt(" Please enter the first " + i + " Second grade "));
				sum += score;
				avg = sum / 5;
				max = max > score ? max : score;
				min = min < score ? min : score;
			}
			document.write("sum=" + sum + "<br/>");
			document.write("avg=" + avg + "<br/>");
			document.write("max=" + max + "<br/>");
			document.write("min=" + min + "<br/>");
            for (var i = 1; i <= 1000; i++) {
				if (i % 2 == 0) {
					document.write(i + "<br/>");
				}

			}
			for (var i = 1; i <= 1000; i++) {
				if (i % 2 != 0) {
					document.write(i + "<br/>");
				}

			}
            for (var i = 1; i <= 50; i++) {
				for (var j = 1; j <= 25; j++) {

					if (2 * i + 4 * j == 100) {
						document.write(" The number of chickens " + i + "_______________" + " The number of rabbits is " + j 
                           + "<br/>");
					}
				}

			}
         for (var i = 9; i >= 1; i--) {
				for (var j = 1; j <= i; j++) {
					document.write("<span>" + j + "*" + i + "=" + (j * i) + "</span>");
				}
				document.write("<br/>");
			}

         span{
				width: 75px;
				display: inline-block;
			}

			body {
				width: 2000px;
			}// stay style Set in 
          for (var i = 100; i < 1000; i++) {
				var bai = parseInt(i / 100);
				var shi = parseInt(i / 10 % 10);
				var ge = parseInt(i % 10);
				if (i == ge * ge * ge + shi * shi * shi + bai * bai * bai) {
					document.write("1000 The number of daffodils within is " + i + "<br/>");
				}
			}
            var avg = 0;
			var sum = 0;
			var score = 0;

			for (var i = 1; i <= 5; i++) {

				score = Number(prompt(" Please enter the first " + i + " Results of courses "));
				if (score < 0) {
					alert(" Stop typing , Input error ");
					break;
				}
				sum += score;
			}
			avg = sum / 5;
			document.write(" The average is divided into " + avg + "<br/>");
// There is an equation    12()34()56()78()9 = 59, Only add and subtract can be placed in brackets , If you want the equation to hold , So what symbols should be placed in each bracket . 
			// With positive and negative 1 Instead of the plus and minus signs 

			for (var a = -1; a < 2; a += 2) {
				for (var b = -1; b < 2; b += 2) {
					for (var c = -1; c < 2; c += 2) {
						for (var d = -1; d < 2; d += 2) {
							if (12 + a * 34 + b * 56 + c * 78 + d * 9 == 59) {
					             document.write(a + "<br/>" + b + "<br/>" + c + "<br/>" + d + "<br/>");
							}

						}
					}
				}
			}

原网站

版权声明
本文为[Fall in love with*]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202200528161061.html