Практикум по программированию. Основы. Циклы. Табулирование функции
From AsIsWiki
Contents |
Java
import java.util.Scanner; public class Task08 { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println(); System.out.println(" Табулирование функции Y = X^2 + 1 "); System.out.println(" на отрезке [A, B] с шагом H "); System.out.println("-----------------------------------"); System.out.print(" Введите границы отрезка A и B: "); double a = in.nextDouble(); double b = in.nextDouble(); System.out.print(" Введите шаг табулирования H: "); double h = in.nextDouble(); System.out.println("-----------------------------------"); System.out.println(" X Y"); for (double x = a; x <= b; x += h) { System.out.printf(" %8.3f %8.3f\n", x, x * x + 1); } } }
C++
// g++ 4.2 #include <iostream> using namespace std; int main() { double a, b, h; cout << "\n Табулирование функции Y = X^2 + 1\n"; cout << " на отрезке [A, B] с шагом H\n"; cout << "-----------------------------------\n"; cout << " Введите границы отрезка A и B: "; cin >> a >> b; cout << " Введите шаг табулирования H: "; cin >> h; cout << "-----------------------------------\n"; cout << " X Y\n"; for (double x = a; x <= b; x += h) { printf(" %8.3f %8.3f\n", x, x * x + 1); } cout << "\n"; return 0; }
Pascal
JavaScript