📜  查找所有类型矩阵的程序

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

查找所有类型矩阵的程序

给定矩阵 R(rows) * C(column) 的维度,任务是找出给定维度表示的矩阵类型。
例子:

Input : R = 1 C = 0
Output : Row Matrix 

Input : R = 4 C = 5
Output : Horizontal Matrix 

C++
// C++ program to check
// types of Matrix
#include 
using namespace std;
 
// Function to display which
// type of matrix
void check(int r, int c)
{
    if (r == 0 && c == 1)
        cout << "Column Matrix " << endl;
    else if (r == 1 && c == 0)
        cout << "Row Matrix " << endl;
    else if (r < c)
        cout << "Horizontal Matrix " << endl;
    else if (r > c)
        cout << "Vertical Matrix " << endl;
    else if (r == c)
        cout << "Square Matrix " << endl;
}
 
// Driver code
int main()
{
    // input for r and c
    // function calling
    check(1, 0);
    check(0, 1);
    check(4, 5);
    check(5, 4);
    check(3, 3);
     
    return 0;
}


Java
// Java program to check
// types of Matrix
import java.io.*;
import java.util.*;
import java.math.*;
import java.util.regex.*;
 
public class GFG {
 
    // Function to display which type of matrix
    static void check(int r, int c)
    {
        if (r == 0 && c == 1)
            System.out.println("Column Matrix ");
        else if (r == 1 && c == 0)
            System.out.println("Row Matrix ");
        else if (r < c)
            System.out.println("Horizontal Matrix ");
        else if (r > c)
            System.out.println("Vertical Matrix ");
        else if (r == c)
            System.out.println("Square Matrix ");
    }
 
    // Driver code
    public static void main(String[] args)
    {
 
        // static input for r and c
        // function calling
        check(1, 0);
        check(0, 1);
        check(4, 5);
        check(5, 4);
        check(3, 3);
    }
}


Python3
# Python3 program to check
# types of Matrix
 
 
# Function to display which
# type of matrix
def check(r, c) :
     
 
    if r == 0 and c == 1:
        print ("Column Matrix ")
         
    elif r == 1 and c == 0:
        print ("Row Matrix ")
     
    elif r < c:
        print ("Horizontal Matrix ")
         
    elif r > c:
        print ("Vertical Matrix ")
         
    elif r == c:
        print ("Square Matrix ")
 
 
# Driver code
check(1, 0)
check(0, 1)
check(4, 5)
check(5, 4)
check(3, 3)
 
# This code is contributed by Sam007.


C#
// C# program to check types of Matrix
using System;
 
class GFG
{
    // Function to display which type of matrix
    static void check(int r, int c)
    {
        if (r == 0 && c == 1)
            Console.WriteLine("Column Matrix ");
        else if (r == 1 && c == 0)
            Console.WriteLine("Row Matrix ");
        else if (r < c)
            Console.WriteLine("Horizontal Matrix ");
        else if (r > c)
            Console.WriteLine("Vertical Matrix ");
        else if (r == c)
            Console.WriteLine("Square Matrix ");
    }
 
    // Driver code
    static void Main()
    {
 
        // static input for r and c
        // function calling
        check(1, 0);
        check(0, 1);
        check(4, 5);
        check(5, 4);
        check(3, 3);
    }
     
}
 
// This code is contributed by Sam007.


PHP
 $c)
        echo "Vertical Matrix "."\n";
    else if ($r == $c)
        echo "Square Matrix "."\n";
}
 
    // Driver code
     
    // input for r and c
    // function calling
    check(1, 0);
    check(0, 1);
    check(4, 5);
    check(5, 4);
    check(3, 3);
     
// This code is contributed by Sam007
?>


Javascript


输出 :

Row Matrix 
Column Matrix 
Horizontal Matrix 
Vertical Matrix 
Square Matrix