📜  线的斜率与具有给定斜率的线平行

📅  最后修改于: 2021-04-22 09:32:35             🧑  作者: 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