当前位置:网站首页>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*36. 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/>");
}
}
}
}
}边栏推荐
- Yunfan mall -- Yunfan mall system development source code sharing
- R language uses the multinom function of NNET package to build an unordered multi classification logistic regression model, and uses the summary function to obtain the summary statistical information
- Polling and long polling
- GPS receiver design (1)
- The dist function of R language calculates the distance between two samples in dataframe data, returns the distance matrix between samples, and specifies the distance calculation method through the me
- Ubuntu uninstalling PHP
- Wechat forbids sharing
- Concat(), join(), reverse(), sort() method in JS array
- Micro engine generates QR code
- Micro engine remote attachment 7 Niu cloud upload
猜你喜欢
![最大数[抽象排序之抽象规则]](/img/47/f6bafacc95f487854a3e304325f3f0.png)
最大数[抽象排序之抽象规则]

MySQL common interview questions

Uncover gaussdb (for redis): comprehensive comparison of CODIS

MySQL and excel tables importing database data (Excel for MySQL)

2022 meisai topic C idea sharing + translation

C program linking SQLSERVER database: instance failed

Jeecgboot startup popup configuration is still incorrect

Zhangxiaobai's way of penetration (V) -- detailed explanation of upload vulnerability and parsing vulnerability
![[on]learning dynamic and hierarchical traffic spatiotemporal features with transformer](/img/58/d68112a3d019de66150e2f5102f436.png)
[on]learning dynamic and hierarchical traffic spatiotemporal features with transformer

Total number of MySQL statistics, used and unused
随机推荐
JS array length is defined
Zunpin Yongyao advertising e-commerce system -- Zunpin Yongyao advertising e-commerce app system development source code sharing
Foreach method of array in JS
Zhangxiaobai's way of penetration (VIII) - detailed operation steps of SQL injection - Boolean blind injection of blind injection
Initialize the project using the express framework
[data midrange] what is the oneid of the data midrange? Isn't the master data fragrant?
Does sklearex make your sklearn machine learning model training fly fast?
Wait for the end of the network request in the uniapp Onshow method before executing the subsequent code content
Online blind box system development function introduction and some source code sharing
(4) Pyqt5 tutorial -- > Custom signal and slot (super winding...)
Arm V7 coprocessor
The server reported an error 503 service unavailable:the system returned: (71) protocol error
Summary of common MySQL database commands (from my own view)
Thinkphp3 use phpword to modify the template and download it
Thinkphp3 count ` *'problem
Arm immediate
2022 meisai e topic ideas sharing + translation
Laravel task scheduling
JQ dynamic setting radio does not take effect when selected
Mind mapping video