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

From AsIsWiki
Revision as of 17:37, 14 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
29
import java.util.Scanner;
 
public class Task17 {
 
    public static void main(String[] args) {
 
        Scanner in = new Scanner(System.in);
 
        System.out.println();
        System.out.println("     Расчет напряженности");
        System.out.println(" электростатического поля сферы");
        System.out.println("--------------------------------");
 
        System.out.print(" Введите заряд сферы: ");
        double q = in.nextDouble();
 
        System.out.print(" Введите радиус сферы: ");
        double r = in.nextDouble();
 
        System.out.print(" Расстояние от центра сферы до исследуемой точки: ");
        double l = in.nextDouble();
 
        System.out.println("--------------------------------");
 
        double e = l < r ? 0 : q / (l * l);
 
        System.out.printf(" Напряженность поля E = %.2f в/м\n", e);
    }
}


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
31
// g++ 4.2
 
#include <iostream>
 
using namespace std;
 
int main() {
     
    double q, r, l;
     
    cout << "\n     Расчет напряженности\n";
    cout << " электростатического поля сферы\n";
    cout << "--------------------------------\n";
     
    cout << " Введите заряд сферы: ";
    cin >> q;
     
    cout << " Введите радиус сферы: ";
    cin >> r;
     
    cout << " Расстояние от центра сферы до исследуемой точки: ";
    cin >> l;
     
    cout << "--------------------------------\n";
     
    double e = l < r ? 0 : q / (l * l);
     
    printf(" Напряженность поля E = %.2f в/м\n\n", e);
     
    return 0;
}


Pascal

1
 


JavaScript

1
 



Назад · Задачи

Personal tools
Namespaces

Variants
Actions
Navigation
Tools