百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 热门文章 > 正文

修改布尔矩阵单元格的值

bigegpt 2024-08-08 11:54 2 浏览

问题:给定大小为MXN的布尔矩阵mat[M][N],请对其进行修改,以使如果矩阵单元mat[i][j]为 1(或true),则使第i行和第j列的所有单元格均为 1。

Example 1
The matrix
1 0
0 0
should be changed to following
1 1
1 0

Example 2
The matrix
0 0 0
0 0 1
should be changed to following
0 0 1
1 1 1

Example 3
The matrix
1 0 0 1
0 0 1 0
0 0 0 0
should be changed to following
1 1 1 1
1 1 1 1
1 0 1 1
复制ErrorOK!

方法 1(使用两个临时数组)

  1. 创建两个临时数组row[M]col[N]。 将row[]col[]的所有值初始化为 0。
  2. 遍历输入矩阵mat[M][N]。 如果看到输入mat[i][j]true,则将row[i]col[j]标记为true
  3. 再次遍历输入矩阵mat[M][N]。 对于每个入口mat[i][j],检查row[i]col[j]的值。 如果两个值(row[i]col[j])中的任何一个为true,则将mat[i][j]标记为true

感谢 Dixit Sethi 提出了这种方法。

C++


// C++ Code For A Boolean Matrix Question 
#include <bits/stdc++.h> 

using namespace std; 
#define R 3 
#define C 4 

void modifyMatrix(bool mat[R][C]) 
{ 
    bool row[R]; 
    bool col[C]; 

    int i, j; 

    /* Initialize all values of row[] as 0 */
    for (i = 0; i < R; i++) 
    { 
    row[i] = 0; 
    } 

    /* Initialize all values of col[] as 0 */
    for (i = 0; i < C; i++) 
    { 
    col[i] = 0; 
    } 

    // Store the rows and columns to be marked as 
    // 1 in row[] and col[] arrays respectively 
    for (i = 0; i < R; i++) 
    { 
        for (j = 0; j < C; j++) 
        { 
            if (mat[i][j] == 1) 
            { 
                row[i] = 1; 
                col[j] = 1; 
            } 
        } 
    } 

    // Modify the input matrix mat[] using the  
    // above constructed row[] and col[] arrays 
    for (i = 0; i < R; i++) 
    { 
        for (j = 0; j < C; j++) 
        { 
            if ( row[i] == 1 || col[j] == 1 ) 
            { 
                mat[i][j] = 1; 
            } 
        } 
    } 
} 

/* A utility function to print a 2D matrix */
void printMatrix(bool mat[R][C]) 
{ 
    int i, j; 
    for (i = 0; i < R; i++) 
    { 
        for (j = 0; j < C; j++) 
        { 
            cout << mat[i][j]; 
        } 
        cout << endl; 
    } 
} 

// Driver Code 
int main() 
{ 
    bool mat[R][C] = { {1, 0, 0, 1}, 
                       {0, 0, 1, 0}, 
                       {0, 0, 0, 0}}; 

    cout << "Input Matrix \n"; 
    printMatrix(mat); 

    modifyMatrix(mat); 

    printf("Matrix after modification \n"); 
    printMatrix(mat); 

    return 0; 
} 

// This code is contributed  
// by Akanksha Rai(Abby_akku) 
复制ErrorOK!

Java

// Java Code For A Boolean Matrix Question 
class GFG 
{ 
    public static void modifyMatrix(int mat[ ][ ], int R, int C) 
    { 
        int row[ ]= new int [R]; 
        int col[ ]= new int [C]; 
        int i, j; 

        /* Initialize all values of row[] as 0 */
        for (i = 0; i < R; i++) 
        { 
        row[i] = 0; 
        } 


        /* Initialize all values of col[] as 0 */
        for (i = 0; i < C; i++) 
        { 
        col[i] = 0; 
        } 


        /* Store the rows and columns to be marked as 
        1 in row[] and col[] arrays respectively */
        for (i = 0; i < R; i++) 
        { 
            for (j = 0; j < C; j++) 
            { 
                if (mat[i][j] == 1) 
                { 
                    row[i] = 1; 
                    col[j] = 1; 
                } 
            } 
        } 

        /* Modify the input matrix mat[] using the 
        above constructed row[] and col[] arrays */
        for (i = 0; i < R; i++) 
        { 
            for (j = 0; j < C; j++) 
            { 
                if ( row[i] == 1 || col[j] == 1 ) 
                { 
                    mat[i][j] = 1; 
                } 
            } 
        } 
    } 

    /* A utility function to print a 2D matrix */
    public static void printMatrix(int mat[ ][ ], int R, int C) 
    { 
        int i, j; 
        for (i = 0; i < R; i++) 
        { 
            for (j = 0; j < C; j++) 
            { 
                System.out.print(mat[i][j]+ " "); 
            } 
            System.out.println(); 
        } 
    } 

    /* Driver program to test above functions */
    public static void main(String[] args)  
    { 
        int mat[ ][ ] = { {1, 0, 0, 1}, 
                          {0, 0, 1, 0}, 
                          {0, 0, 0, 0},}; 

                System.out.println("Matrix Intially"); 

                printMatrix(mat, 3, 4); 

                modifyMatrix(mat, 3, 4); 
                System.out.println("Matrix after modification n"); 
                printMatrix(mat, 3, 4); 

    }  

} 

// This code is contributed by Kamal Rawal 复制ErrorOK!

Python3

# Python3 Code For A Boolean Matrix Question 
R = 3
C = 4

def modifyMatrix(mat): 
    row = [0] * R  
    col = [0] * C  

    # Initialize all values of row[] as 0  
    for i in range(0, R): 
        row[i] = 0

    # Initialize all values of col[] as 0  
    for i in range(0, C) : 
        col[i] = 0


    # Store the rows and columns to be marked  
    # as 1 in row[] and col[] arrays respectively  
    for i in range(0, R) : 

        for j in range(0, C) : 
            if (mat[i][j] == 1) : 
                row[i] = 1
                col[j] = 1

    # Modify the input matrix mat[] using the  
    # above constructed row[] and col[] arrays  
    for i in range(0, R) : 

        for j in range(0, C): 
            if ( row[i] == 1 or col[j] == 1 ) : 
                mat[i][j] = 1

# A utility function to print a 2D matrix  
def printMatrix(mat) : 
    for i in range(0, R): 

        for j in range(0, C) : 
            print(mat[i][j], end = " ") 
        print() 

# Driver Code 
mat = [ [1, 0, 0, 1], 
        [0, 0, 1, 0], 
        [0, 0, 0, 0] ]  

print("Input Matrix n") 
printMatrix(mat) 

modifyMatrix(mat) 

print("Matrix after modification n") 
printMatrix(mat) 

# This code is contributed by Nikita Tiwari. 复制ErrorOK!

C#

// C# Code For A Boolean 
// Matrix Question 
using System; 

class GFG 
{ 
    public static void modifyMatrix(int [,]mat,  
                                    int R, int C) 
    { 
        int []row = new int [R]; 
        int []col = new int [C]; 
        int i, j; 

        /* Initialize all values 
        of row[] as 0 */
        for (i = 0; i < R; i++) 
        { 
        row[i] = 0; 
        } 


        /* Initialize all values 
        of col[] as 0 */
        for (i = 0; i < C; i++) 
        { 
        col[i] = 0; 
        } 


        /* Store the rows and columns  
        to be marked as 1 in row[]  
        and col[] arrays respectively */
        for (i = 0; i < R; i++) 
        { 
            for (j = 0; j < C; j++) 
            { 
                if (mat[i, j] == 1) 
                { 
                    row[i] = 1; 
                    col[j] = 1; 
                } 
            } 
        } 

        /* Modify the input matrix  
        mat[] using the above  
        constructed row[] and  
        col[] arrays */
        for (i = 0; i < R; i++) 
        { 
            for (j = 0; j < C; j++) 
            { 
                if (row[i] == 1 || col[j] == 1) 
                { 
                    mat[i, j] = 1; 
                } 
            } 
        } 
    } 

    /* A utility function to 
    print a 2D matrix */
    public static void printMatrix(int [,]mat,  
                                   int R, int C) 
    { 
        int i, j; 
        for (i = 0; i < R; i++) 
        { 
            for (j = 0; j < C; j++) 
            { 
                Console.Write(mat[i, j] + " "); 
            } 
            Console.WriteLine(); 
        } 
    } 

    // Driver code 
    static public void Main () 
    { 
        int [,]mat = {{1, 0, 0, 1}, 
                      {0, 0, 1, 0}, 
                      {0, 0, 0, 0}}; 

        Console.WriteLine("Matrix Intially"); 

        printMatrix(mat, 3, 4); 

        modifyMatrix(mat, 3, 4); 
        Console.WriteLine("Matrix after "+ 
                        "modification n"); 
        printMatrix(mat, 3, 4); 

    } 
} 

// This code is contributed by ajit 复制ErrorOK!

PHP

<?php  
// PHP Code For A Boolean 
// Matrix Question 
$R = 3; 
$C = 4; 

function modifyMatrix(&$mat) 
{ 
    global $R,$C; 
    $row = array(); 
    $col = array(); 

    /* Initialize all values  
       of row[] as 0 */
    for ($i = 0; $i < $R; $i++) 
    { 
        $row[$i] = 0; 
    } 


    /* Initialize all values  
       of col[] as 0 */
    for ($i = 0; $i < $C; $i++) 
    { 
        $col[$i] = 0; 
    } 


    /* Store the rows and columns  
       to be marked as 1 in row[]  
       and col[] arrays respectively */
    for ($i = 0; $i < $R; $i++) 
    { 
        for ($j = 0; $j < $C; $j++) 
        { 
            if ($mat[$i][$j] == 1) 
            { 
                $row[$i] = 1; 
                $col[$j] = 1; 
            } 
        } 
    } 

    /* Modify the input matrix mat[] 
       using the above constructed  
       row[] and col[] arrays */
    for ($i = 0; $i < $R; $i++) 
    { 
        for ($j = 0; $j < $C; $j++) 
        { 
            if ($row[$i] == 1 ||  
                $col[$j] == 1 ) 
            { 
                $mat[$i][$j] = 1; 
            } 
        } 
    } 
} 

/* A utility function to 
   print a 2D matrix */
function printMatrix(&$mat) 
{ 
    global $R, $C; 
    for ($i = 0; $i < $R; $i++) 
    { 
        for ($j = 0; $j < $C; $j++) 
        { 
            echo $mat[$i][$j] . " "; 
        } 
        echo "\n"; 
    } 
} 

// Driver code  
$mat = array(array(1, 0, 0, 1), 
             array(0, 0, 1, 0), 
             array(0, 0, 0, 0)); 

echo "Input Matrix \n"; 
printMatrix($mat); 

modifyMatrix($mat); 

echo "Matrix after modification \n"; 
printMatrix($mat); 

// This code is contributed  
// by ChitraNayal 
?> 复制ErrorOK!

输出:

Input Matrix
1 0 0 1
0 0 1 0
0 0 0 0
Matrix after modification
1 1 1 1
1 1 1 1
1 0 1 1复制ErrorOK!

时间复杂度:O(M * N)

辅助空间:O(M + N)

方法 2(方法 1 的空间优化版本):

该方法是上述方法 1 的空间优化版本。该方法使用输入矩阵的第一行和第一列代替方法 1 的辅助数组row[]col[]。因此,我们要做的是:首先注意第一行和第一列,并将这两个信息存储在两个标志变量rowFlagcolFlag中。获得此信息后,我们可以将第一行和第一列用作辅助数组,并将方法1应用于大小为(M-1) * (N-1))的子矩阵(不包括第一行和第一列的矩阵)。

1)扫描第一行并设置一个变量rowFlag以指示是否需要在第一行中设置全 1。 2)扫描第一列并设置变量colFlag以指示是否需要在第一列中设置全 1。 3)分别使用第一行和第一列作为辅助数组row[]col[],将矩阵视为从第二行和第二列开始的子矩阵,并应用方法 1。 4)最后,如果需要,使用rowFlagcolFlag更新第一行和第一列。

时间复杂度:O(M * N)

辅助空间:O(1)

感谢 Sidh 提出了这种方法。

C++

#include <bits/stdc++.h> 
using namespace std; 
#define R 3 
#define C 4 

void modifyMatrix(int mat[R][C]) 
{ 
    // variables to check if there are any 1 
    // in first row and column 
    bool row_flag = false; 
    bool col_flag = false; 

    // updating the first row and col if 1 
    // is encountered 
    for (int i = 0; i < R; i++) { 
        for (int j = 0; j < C; j++) { 
            if (i == 0 && mat[i][j] == 1) 
                row_flag = true; 

            if (j == 0 && mat[i][j] == 1) 
                col_flag = true; 

            if (mat[i][j] == 1) { 

                mat[0][j] = 1; 
                mat[i][0] = 1; 
            } 
        } 
    } 

    // Modify the input matrix mat[] using the 
    // first row and first column of Matrix mat 
    for (int i = 1; i < R; i++) { 
        for (int j = 1; j < C; j++) { 

            if (mat[0][j] == 1 || mat[i][0] == 1) { 
                mat[i][j] = 1; 
            } 
        } 
    } 

    // modify first row if there was any 1 
    if (row_flag == true) { 
        for (int i = 0; i < C; i++) { 
            mat[0][i] = 1; 
        } 
    } 

    // modify first col if there was any 1 
    if (col_flag == true) { 
        for (int i = 0; i < R; i++) { 
            mat[i][0] = 1; 
        } 
    } 
} 

/* A utility function to print a 2D matrix */
void printMatrix(int mat[R][C]) 
{ 
    for (int i = 0; i < R; i++) { 
        for (int j = 0; j < C; j++) { 
            cout << mat[i][j]; 
        } 
        cout << "\n"; 
    } 
} 

// Driver function to test the above function 
int main() 
{ 

    int mat[R][C] = { { 1, 0, 0, 1 }, 
                      { 0, 0, 1, 0 }, 
                      { 0, 0, 0, 0 } }; 

    cout << "Input Matrix :\n"; 
    printMatrix(mat); 

    modifyMatrix(mat); 

    cout << "Matrix After Modification :\n"; 
    printMatrix(mat); 
    return 0; 
} 

// This code is contributed by Nikita Tiwari 复制ErrorOK!

Java

class GFG 
{  
    public static void modifyMatrix(int mat[][]){ 

        // variables to check if there are any 1  
        // in first row and column 
        boolean row_flag = false; 
        boolean col_flag = false; 

        // updating the first row and col if 1 
        // is encountered 
        for (int i = 0; i < mat.length; i++ ){ 
                for (int j = 0; j < mat[0].length; j++){ 
                        if (i == 0 && mat[i][j] == 1) 
                            row_flag = true; 

                        if (j == 0 && mat[i][j] == 1) 
                            col_flag = true; 

                        if (mat[i][j] == 1){ 

                            mat[0][j] = 1; 
                            mat[i][0] = 1; 
                        } 

                    } 
                } 

        // Modify the input matrix mat[] using the  
        // first row and first column of Matrix mat 
        for (int i = 1; i < mat.length; i ++){ 
                for (int j = 1; j < mat[0].length; j ++){ 

                    if (mat[0][j] == 1 || mat[i][0] == 1){ 
                            mat[i][j] = 1; 
                        } 
                    } 
                } 

        // modify first row if there was any 1 
        if (row_flag == true){ 
            for (int i = 0; i < mat[0].length; i++){ 
                        mat[0][i] = 1; 
                    } 
                } 

        // modify first col if there was any 1 
        if (col_flag == true){ 
            for (int i = 0; i < mat.length; i ++){ 
                        mat[i][0] = 1; 
            } 
        } 
    } 

    /* A utility function to print a 2D matrix */
    public static void printMatrix(int mat[][]){ 
        for (int i = 0; i < mat.length; i ++){ 
            for (int j = 0; j < mat[0].length; j ++){ 
                System.out.print( mat[i][j] ); 
            } 
                System.out.println(""); 
        } 
    } 

    // Driver function to test the above function 
    public static void main(String args[] ){ 

        int mat[][] = {{1, 0, 0, 1}, 
                {0, 0, 1, 0}, 
                {0, 0, 0, 0}}; 

        System.out.println("Input Matrix :"); 
        printMatrix(mat); 

        modifyMatrix(mat); 

        System.out.println("Matrix After Modification :"); 
        printMatrix(mat); 

    } 
} 

// This code is contributed by Arnav Kr. Mandal. 复制ErrorOK!

Python3

# Python3 Code For A Boolean Matrix Question 
def modifyMatrix(mat) : 

    # variables to check if there are any 1  
    # in first row and column 
    row_flag = False
    col_flag = False

    # updating the first row and col  
    # if 1 is encountered 
    for i in range(0, len(mat)) : 

        for j in range(0, len(mat)) : 
            if (i == 0 and mat[i][j] == 1) : 
                row_flag = True

            if (j == 0 and mat[i][j] == 1) : 
                col_flag = True

            if (mat[i][j] == 1) : 
                mat[0][j] = 1
                mat[i][0] = 1

    # Modify the input matrix mat[] using the  
    # first row and first column of Matrix mat 
    for i in range(1, len(mat)) : 

        for j in range(1, len(mat) + 1) : 
            if (mat[0][j] == 1 or mat[i][0] == 1) : 
                mat[i][j] = 1

    # modify first row if there was any 1 
    if (row_flag == True) : 
        for i in range(0, len(mat)) : 
            mat[0][i] = 1

    # modify first col if there was any 1 
    if (col_flag == True) : 
        for i in range(0, len(mat)) : 
            mat[i][0] = 1

# A utility function to print a 2D matrix 
def printMatrix(mat) : 

    for i in range(0, len(mat)) : 
        for j in range(0, len(mat) + 1) : 
            print( mat[i][j], end = "" ) 

        print() 

# Driver Code 
mat = [ [1, 0, 0, 1], 
        [0, 0, 1, 0], 
        [0, 0, 0, 0] ] 

print("Input Matrix :") 
printMatrix(mat) 

modifyMatrix(mat) 

print("Matrix After Modification :") 
printMatrix(mat) 

# This code is contributed by Nikita tiwari. 复制ErrorOK!

C#

// C# Code For A Boolean 
// Matrix Question 
using System; 

class GFG 
{  
    public static void modifyMatrix(int[,] mat) 
    { 

        // variables to check  
        // if there are any 1  
        // in first row and column 
        bool row_flag = false; 
        bool col_flag = false; 

        // updating the first 
        // row and col if 1 
        // is encountered 
        for (int i = 0; 
                 i < mat.GetLength(0); i++ ) 
        { 
                for (int j = 0;  
                         j < mat.GetLength(1); j++) 
                { 
                        if (i == 0 && mat[i, j] == 1) 
                            row_flag = true; 

                        if (j == 0 && mat[i, j] == 1) 
                            col_flag = true; 

                        if (mat[i, j] == 1) 
                        { 
                            mat[0, j] = 1; 
                            mat[i,0] = 1; 
                        } 

                    } 
                } 

        // Modify the input matrix mat[]  
        // using the first row and first 
        // column of Matrix mat 
        for (int i = 1;  
                 i < mat.GetLength(0); i ++) 
        { 
                for (int j = 1;  
                         j < mat.GetLength(1); j ++) 
                { 

                    if (mat[0, j] == 1 ||  
                        mat[i, 0] == 1) 
                    { 
                            mat[i, j] = 1; 
                        } 
                    } 
                } 

        // modify first row 
        // if there was any 1 
        if (row_flag == true) 
        { 
            for (int i = 0;  
                     i < mat.GetLength(1); i++) 
            { 
                        mat[0, i] = 1; 
            } 
        } 

        // modify first col if 
        // there was any 1 
        if (col_flag == true) 
        { 
            for (int i = 0;  
                     i < mat.GetLength(0); i ++) 
            { 
                        mat[i, 0] = 1; 
            } 
        } 
    } 

    /* A utility function  
    to print a 2D matrix */
    public static void printMatrix(int[,] mat) 
    { 
        for (int i = 0;  
                 i < mat.GetLength(0); i ++) 
        { 
            for (int j = 0;  
                     j < mat.GetLength(1); j ++) 
            { 
                Console.Write(mat[i, j] + " " ); 
            } 
                Console.Write("\n"); 
        } 
    } 

    // Driver Code 
    public static void Main() 
    { 
        int[,] mat = {{1, 0, 0, 1}, 
                      {0, 0, 1, 0}, 
                      {0, 0, 0, 0}}; 

        Console.Write("Input Matrix :\n"); 
        printMatrix(mat); 

        modifyMatrix(mat); 

        Console.Write("Matrix After " +  
                      "Modification :\n"); 
        printMatrix(mat); 
    } 
} 

// This code is contributed 
// by ChitraNayal 复制ErrorOK!

PHP

<?php  
// PHP Code For A Boolean 
// Matrix Question 
$R = 3; 
$C = 4; 

function modifyMatrix(&$mat) 
{ 
    global $R, $C; 

    // variables to check if  
    // there are any 1 in  
    // first row and column 
    $row_flag = false; 
    $col_flag = false; 

    // updating the first  
    // row and col if 1 
    // is encountered 
    for ($i = 0; $i < $R; $i++)  
    { 
        for ($j = 0; $j < $C; $j++)  
        { 
            if ($i == 0 && $mat[$i][$j] == 1) 
                $row_flag = true; 

            if ($j == 0 && $mat[$i][$j] == 1) 
                $col_flag = true; 

            if ($mat[$i][$j] == 1)  
            { 
                $mat[0][$j] = 1; 
                $mat[$i][0] = 1; 
            } 
        } 
    } 

    // Modify the input matrix  
    // mat[] using the first  
    // row and first column of  
    // Matrix mat 
    for ($i = 1; $i < $R; $i++)  
    { 
        for ($j = 1; $j < $C; $j++) 
        { 
            if ($mat[0][$j] == 1 ||  
                $mat[$i][0] == 1) 
            { 
                $mat[$i][$j] = 1; 
            } 
        } 
    } 

    // modify first row  
    // if there was any 1 
    if ($row_flag == true)  
    { 
        for ($i = 0; $i < $C; $i++) 
        { 
            $mat[0][$i] = 1; 
        } 
    } 

    // modify first col  
    // if there was any 1 
    if ($col_flag == true)  
    { 
        for ($i = 0; $i < $R; $i++) 
        { 
            $mat[$i][0] = 1; 
        } 
    } 
} 

/* A utility function 
to print a 2D matrix */
function printMatrix(&$mat) 
{ 
    global $R, $C; 
    for ($i = 0; $i < $R; $i++)  
    { 
        for ($j = 0; $j < $C; $j++) 
        { 
            echo $mat[$i][$j]." "; 
        } 
        echo "\n"; 
    } 
} 

// Driver Code 
$mat = array(array(1, 0, 0, 1 ), 
             array(0, 0, 1, 0 ), 
             array(0, 0, 0, 0 )); 

echo "Input Matrix :\n"; 
printMatrix($mat); 

modifyMatrix($mat); 

echo "Matrix After Modification :\n"; 
printMatrix($mat); 

// This code is conrtributed  
// by ChitraNayal 
?> 复制ErrorOK!

输出:

Input Matrix :
1001
0010
0000
Matrix After Modification :
1111
1111
1011

相关推荐

【Docker 新手入门指南】第十章:Dockerfile

Dockerfile是Docker镜像构建的核心配置文件,通过预定义的指令集实现镜像的自动化构建。以下从核心概念、指令详解、最佳实践三方面展开说明,帮助你系统掌握Dockerfile的使用逻...

Windows下最简单的ESP8266_ROTS_ESP-IDF环境搭建与腾讯云SDK编译

前言其实也没啥可说的,只是我感觉ESP-IDF对新手来说很不友好,很容易踩坑,尤其是对业余DIY爱好者搭建环境非常困难,即使有官方文档,或者网上的其他文档,但是还是很容易踩坑,多研究,记住两点就行了,...

python虚拟环境迁移(python虚拟环境conda)

主机A的虚拟环境向主机B迁移。前提条件:主机A和主机B已经安装了virtualenv1.主机A操作如下虚拟环境目录:venv进入虚拟环境:sourcevenv/bin/active(1)记录虚拟环...

Python爬虫进阶教程(二):线程、协程

简介线程线程也叫轻量级进程,它是一个基本的CPU执行单元,也是程序执行过程中的最小单元,由线程ID、程序计数器、寄存器集合和堆栈共同组成。线程的引入减小了程序并发执行时的开销,提高了操作系统的并发性能...

基于网络安全的Docker逃逸(docker)

如何判断当前机器是否为Docker容器环境Metasploit中的checkcontainer模块、(判断是否为虚拟机,checkvm模块)搭配学习教程1.检查根目录下是否存在.dockerenv文...

Python编程语言被纳入浙江高考,小学生都开始学了

今年9月份开始的新学期,浙江省三到九年级信息技术课将同步替换新教材。其中,新初二将新增Python编程课程内容。新高一信息技术编程语言由VB替换为Python,大数据、人工智能、程序设计与算法按照教材...

CentOS 7下安装Python 3.10的完整过程

1.安装相应的编译工具yum-ygroupinstall"Developmenttools"yum-yinstallzlib-develbzip2-develope...

如何在Ubuntu 20.04上部署Odoo 14

Odoo是世界上最受欢迎的多合一商务软件。它提供了一系列业务应用程序,包括CRM,网站,电子商务,计费,会计,制造,仓库,项目管理,库存等等,所有这些都无缝集成在一起。Odoo可以通过几种不同的方式进...

Ubuntu 系统安装 PyTorch 全流程指南

当前环境:Ubuntu22.04,显卡为GeForceRTX3080Ti1、下载显卡驱动驱动网站:https://www.nvidia.com/en-us/drivers/根据自己的显卡型号和...

spark+python环境搭建(python 环境搭建)

最近项目需要用到spark大数据相关技术,周末有空spark环境搭起来...目标spark,python运行环境部署在linux服务器个人通过vscode开发通过远程python解释器执行代码准备...

centos7.9安装最新python-3.11.1(centos安装python环境)

centos7.9安装最新python-3.11.1centos7.9默认安装的是python-2.7.5版本,安全扫描时会有很多漏洞,比如:Python命令注入漏洞(CVE-2015-2010...

Linux系统下,五大步骤安装Python

一、下载Python包网上教程大多是通过官方地址进行下载Python的,但由于国内网络环境问题,会导致下载很慢,所以这里建议通过国内镜像进行下载例如:淘宝镜像http://npm.taobao.or...

centos7上安装python3(centos7安装python3.7.2一键脚本)

centos7上默认安装的是python2,要使用python3则需要自行下载源码编译安装。1.安装依赖yum-ygroupinstall"Developmenttools"...

利用本地数据通过微调方式训练 本地DeepSeek-R1 蒸馏模型

网络上相应的教程基本都基于LLaMA-Factory进行,本文章主要顺着相应的教程一步步实现大模型的微调和训练。训练环境:可自行定义,mac、linux或者window之类的均可以,本文以ma...

【法器篇】天啦噜,库崩了没备份(天啦噜是什么意思?)

背景数据库没有做备份,一天突然由于断电或其他原因导致无法启动了,且设置了innodb_force_recovery=6都无法启动,里面的数据怎么才能恢复出来?本例采用解析建表语句+表空间传输的方式进行...