Практикум по программированию. Основы. Циклы. Табулирование функции

From AsIsWiki
Revision as of 11:12, 22 March 2016 by Alex (Talk | contribs)

Jump to: navigation, search

Назад · Задачи · Дальше


Contents

 [hide

Java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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++

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// 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

1
 


JavaScript

1
 



Назад · Задачи · Дальше

Personal tools
Namespaces

Variants
Actions
Navigation
Tools