Практикум по программированию. Основы. Ввод и вывод. Средняя загруженность
From AsIsWiki
(Difference between revisions)
Line 67: | Line 67: | ||
return 0; | return 0; | ||
} | } | ||
+ | </source> | ||
+ | |||
+ | |||
+ | ==Python== | ||
+ | |||
+ | <source lang="python"> | ||
+ | # Python 3 | ||
+ | |||
+ | print("\n Расчет средней загруженности рабочих") | ||
+ | print("--------------------------------------") | ||
+ | |||
+ | s = float(input(" Введите число часов для отработки: ")) | ||
+ | n = float(input(" Введите количество рабочих: ")) | ||
+ | |||
+ | print("--------------------------------------") | ||
+ | |||
+ | z = s / n | ||
+ | |||
+ | print(" Средняя загруженность одного человека: %.2f" % z) | ||
</source> | </source> | ||
Revision as of 13:14, 7 October 2017
Contents |
Java
import java.util.Scanner; public class Task02 { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println(); System.out.println(" Расчет средней загруженности рабочих"); System.out.println("--------------------------------------"); System.out.print(" Введите число часов для отработки: "); int s = in.nextInt(); System.out.print(" Введите количество рабочих: "); int n = in.nextInt(); System.out.println("--------------------------------------"); double z = (double) s / n; System.out.printf(" Средняя загруженность одного человека: %.2f\n", z); } }
C++
// g++ 4.2 #include <iostream> using namespace std; int main() { int s, n; cout << "\n Расчет средней загруженности рабочих\n"; cout << "--------------------------------------\n"; cout << " Введите число часов для отработки: "; cin >> s; cout << " Введите количество рабочих: "; cin >> n; cout << "--------------------------------------\n"; double z = (double) s / n; printf(" Средняя загруженность одного человека: %.2f\n\n", z); return 0; }
Python
# Python 3 print("\n Расчет средней загруженности рабочих") print("--------------------------------------") s = float(input(" Введите число часов для отработки: ")) n = float(input(" Введите количество рабочих: ")) print("--------------------------------------") z = s / n print(" Средняя загруженность одного человека: %.2f" % z)
Pascal
program Task02; var s, n: integer; z: real; begin writeln; writeln(' Расчет средней загруженности рабочих'); writeln('--------------------------------------'); write(' Введите число часов для отработки: '); readln(s); write(' Введите количество рабочих: '); readln(n); writeln('--------------------------------------'); z := s / n; writeln(' Средняя загруженность одного человека: ', z:0:2); readln; end.
JavaScript
<html lang="ru"> <head> <meta charset="UTF-8"> <script> function calc() { var s = document.getElementById("sId").value; var n = document.getElementById("nId").value; var z = s / n; document.getElementById("resultId").innerHTML = "Средняя загруженность одного человека: " + z.toFixed(2); } </script> </head> <body> <p>Расчет средней загруженности рабочих</p> <hr> <p>Введите число часов для отработки: <input id="sId" size="5"></p> <p>Введите количество рабочих: <input id="nId" size="5"></p> <hr> <p id="resultId"></p> <button onclick="calc()">Рассчитать</button> </body> </html>