Last active
May 5, 2023 15:32
-
-
Save renderlife/dac58a6ffca793a1f60c38adb5fa94da to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
<style> | |
body { | |
background-color: #FFFCCC; | |
} | |
h3 { | |
color: rgb(13, 88, 32); | |
} | |
.inputs { | |
color: red; | |
width: 300px; | |
} | |
#result { | |
font-size: 25px; | |
color: green; | |
font-weight: bold; | |
} | |
</style> | |
<script src="artem.js"></script> | |
</head> | |
<body> | |
<div>0. 1 0 1 1 1 1 0 1 0 1</div> | |
<div>1. 1 0 1 0 1 1 0 1 0 1</div> | |
<div>2. 1 0 1 0 1 0 0 0 0 1</div> | |
<div>...</div> | |
<div>10. 1 0 1 0 1 1 0 1 0 1</div> | |
<button onclick="getResult()">Получить результат</button> | |
<h3>Результат</h3> | |
<div id="result"></div> | |
</body> | |
</html> |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
<style> | |
body { | |
background-color: #FFFCCC; | |
} | |
h3 { | |
color: rgb(13, 88, 32); | |
} | |
.inputs { | |
color: red; | |
width: 300px; | |
} | |
#result { | |
font-size: 25px; | |
color: green; | |
font-weight: bold; | |
} | |
</style> | |
</head> | |
<body> | |
Lopez Bryan Simmons Miller Ellis alexander hernandez Sanchez Howard kennedy | |
<input id="lastname" class="inputs" type="text" placeholder="Введите фамилии через пробел"> | |
<button onclick="getResult()">Получить результат</button> | |
<h3>Результат</h3> | |
<div id="result"></div> | |
<script> | |
function getResult () { | |
let elem = document.getElementById('lastname'); | |
let lastNamesStr = elem.value; | |
let lastNamesArr = lastNamesStr.split(' '); | |
let countUpper = 0; | |
let result = 0 | |
for (let index = 0; index < lastNamesArr.length; index++) { | |
let firstCharacter = lastNamesArr[index][0]; | |
if (firstCharacter && firstCharacter.toLowerCase() !== firstCharacter) { | |
countUpper = countUpper + 1; | |
} | |
} | |
result = Math.round((countUpper * 100 / lastNamesArr.length)); | |
document.querySelector('#result').innerHTML = result; | |
} | |
</script> | |
</body> | |
</html> |
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
function getResult () { | |
let resultShoot = [ | |
// [1, 1, 1, 1, 1], | |
// [1, 1, 1, 1, 1], | |
// [1, 1, 1, 1, 1], | |
// [1, 1, 1, 1, 1], | |
// [1, 1, 1, 1, 1], | |
// [1, 1, 1, 1, 1], | |
// [1, 1, 1, 1, 1], | |
// [1, 1, 1, 1, 1], | |
[1, 0, 1, 1, 1], | |
[1, 0, 1, 1, 1], | |
[0, 0, 1, 1, 1], | |
[1, 1, 0, 1, 1], | |
[1, 0, 0, 1, 1], | |
[1, 0, 1, 1, 0], | |
]; | |
let resultNumberSchoolboys = [] | |
let topResult = null | |
//console.log('resultShoot', resultShoot) | |
// Цикл и логика | |
console.log('resultShoot.length', resultShoot.length) | |
for (let i = 0; i < resultShoot.length; i++) { | |
const currentResult = resultShoot[i]; | |
console.log('Результаты ученика #' + i, currentResult) | |
let tempResult = 0 | |
for (let j = 0; j < currentResult.length; j++) { | |
tempResult = tempResult + currentResult[j] | |
} | |
console.log('----- всего попаданий ученика #' + i, tempResult) | |
// || - или | |
// && - и | |
if (topResult === null && tempResult !== 0) { | |
topResult = tempResult | |
resultNumberSchoolboys.push(i) | |
} else if (tempResult > topResult) { | |
resultNumberSchoolboys = [] | |
topResult = tempResult | |
resultNumberSchoolboys.push(i) | |
} else if (tempResult === topResult) { | |
resultNumberSchoolboys.push(i) | |
} | |
} | |
if (resultShoot.length === resultNumberSchoolboys.length) { | |
console.log('Все участники набрали одинаковое кол-ва баллов. Соревнование отменяется') | |
} else if (resultNumberSchoolboys.length > 1) { | |
console.log('Победители ученики №', resultNumberSchoolboys) | |
} else if (resultNumberSchoolboys.length === 0) { | |
console.log('У нас нет победителей, все промахнулись') | |
} else { | |
console.log('Победитель ученик №', resultNumberSchoolboys[0]) | |
} | |
document.querySelector('#result').innerHTML = result ? result : 'Нет результата!!!'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment