Algorithm
本周算法:48.旋轉(zhuǎn)圖像(未解出)
題解思路:使用兩次翻轉(zhuǎn)來實現(xiàn)旋轉(zhuǎn)效果,首先第一次翻轉(zhuǎn)涩盾,將對應(yīng)的行數(shù)字移動至它旋轉(zhuǎn)后應(yīng)在的數(shù)組中十气,但是位置并不一定正確,比如7原先在索引為2的數(shù)組旁赊,通過翻轉(zhuǎn)將它移動至索引為0的數(shù)組中桦踊。第二次翻轉(zhuǎn)則將每個一維數(shù)組進行反轉(zhuǎn)操作,將對應(yīng)數(shù)字移動到正確的位置终畅。
題解代碼
class Solution {
public void rotate(int[][] matrix) {
int n = matrix.length;
for (int i = 0; i < n; i ++) {
for (int j = i; j < n; j++) {
int temp = matrix[i][j];
matrix[i][j] = matrix[j][i];
matrix[j][i] = temp;
}
}
for (int i = 0; i < n; i ++) {
for (int j = 0; j < n / 2; j++) {
int tmp = matrix[i][j];
matrix[i][j] = matrix[i][n - j - 1];
matrix[i][n - j - 1] = tmp;
}
}
}
}
Review
略
Tip
以下是關(guān)于cp命令的使用
cp usage
\cp -rf file1.txt file2.txt
cp前加上\ 在存在相同文件時籍胯,進行覆蓋而不提示
-r -R Copy directories recursively. 遞歸復(fù)制文件及文件夾
-f If an existing destination file cannot be opened, remove it and try again. This option has no effect if the -n/--no-clobber option is used. However, it applies independently of -i/--interactive; neither option cancels the effect of the other,如果目標文件存在,強制將其刪除离福,并重新執(zhí)行復(fù)制操作杖狼。
Share
這是一篇關(guān)于FTP服務(wù)器安裝的過程,我已根據(jù)這篇文章成功搭建出對應(yīng)的FTP服務(wù)器妖爷。
ftp安裝