📜  镜头的力量

📅  最后修改于: 2022-05-13 01:57:59.397000             🧑  作者: Mango

镜头的力量

编写程序来确定镜片的光焦度。
镜片的力量是它弯曲光线的能力。对于凸透镜,会聚能力由光焦度定义,而在凹透镜中,则由发散能力定义。屈光度 (D) 是衡量镜片屈光度的单位。
功率定义为焦距的倒数,以米为单位。
D = ( 1 / F )
这里,D 是屈光度的幂,
F是以米为单位的焦距。
例子:

Input : F = 2
Output : D = 0.5

Input : F = 0.2
Output : D = 5

C++
// C++ program to determine
// the power of a lens
#include 
using namespace std;
 
// function to determine the
// power of a lens
float power(float focal_length)
{
    return (1 / focal_length);
}
 
// driver function
int main()
{
    float focal_length = 2;
    cout << "The power of the lens in diopter is "
         << power(focal_length);
     
    return 0;
}


Java
// Java program to determine
// the power of a lens
import java.io.*;
 
class GFG
{
    // function to determine the
    // power of a lens
    static float power(float focal_length)
    {
        return (1 / focal_length);
    }
     
    // Driver code
    public static void main (String[] args)
    {
        float focal_length = 2;
        System.out.println("The power of the lens in diopter is "
                           + power(focal_length));
         
    }
}
 
// This code is contributed by Gitanjali.


Python3
# Python3 program to determine
# the power of a lens
 
# function to determine
# the power of a lens
def power( focal_length ) :
 
    return ( 1 / focal_length )
 
# driver function
focal_length = 2 ;
print ( "The power of the lens in diopter is ", end = "")
print (power(focal_length) )


C#
// C# program to determine
// the power of a lens
using System;
 
class GFG
{
    // function to determine the
    // power of a lens
    static float power(float focal_length)
    {
        return (1 / focal_length);
    }
     
    // Driver code
    public static void Main ()
    {
        float focal_length = 2;
        Console.WriteLine("The power of the lens in diopter is "
                        + power(focal_length));
         
    }
}
 
// This code is contributed by vt_m.


PHP


Javascript


输出:

The power of the lens in diopter is 0.5

资源:
http://www.bbc.co.uk/bitesize/intermediate2/physics/waves_and_optics/power_of_lens/revision/1/