📜  平行于给定斜率的直线的斜率

📅  最后修改于: 2021-10-23 08:31:23             🧑  作者: Mango

给定一个整数m ,它是一条直线的斜率,任务是找到与给定直线平行的直线的斜率。
例子:

方法:

PQ是两条平行线,方程分别为y = m1x + b1y = m2x + b2 。这里m1m2分别是直线的斜率。现在由于线是平行的,它们没有任何交点,因此将没有线的解决方案系统。所以,让我们试着解方程,

下面是上述方法的实现:

C++
// C++ implementation of the approach
#include 
using namespace std;
 
// Function to return the slope
// of the line which is parallel to
// the line with the given slope
double getSlope(double m)
{
    return m;
}
 
// Driver code
int main()
{
    double m = 2;
    cout << getSlope(m);
 
    return 0;
}


Java
// Java implementation of the approach
class GfG
{
     
// Function to return the slope
// of the line which is parallel to
// the line with the given slope
static double getSlope(double m)
{
    return m;
}
 
// Driver code
public static void main(String[] args)
{
    double m = 2;
    System.out.println(getSlope(m));
}
}
 
// This code is contributed by Code_Mech.


Python3
# Python3 implementation of the approach
 
# Function to return the slope
# of the line which is parallel to
# the line with the given slope
def getSlope(m):
 
    return m;
 
# Driver code
m = 2;
print(getSlope(m));
 
# This code is contributed
# by Akanksha Rai


C#
// C# implementation of the approach
class GFG
{
     
// Function to return the slope
// of the line which is parallel to
// the line with the given slope
static double getSlope(double m)
{
    return m;
}
 
// Driver code
static void Main()
{
    double m = 2;
    System.Console.Write(getSlope(m));
}
}
 
// This code is contributed by mits


PHP


Javascript


输出:
2