01 08 力扣題目 檢查兩個字串陣列是否相等

2021-10-14 07:29:41 字數 677 閱讀 7278

給你兩個字串陣列 word1 和 word2 。如果兩個陣列表示的字串相同,返回 true ;否則,返回 false 。

陣列表示的字串 是由陣列中的所有元素 按順序 連線形成的字串

首先遍歷兩個陣列,將兩個陣列遍歷輸出後存入乙個新的字串裡面,然後用equals方法將兩個新的字串進行比較,相等返回true,不相等返回false

public

class

arraystringsareequal

; string[

] word2 =

;boolean b =

arraystringsareequal

(word1, word2)

; system.out.

println

(b);

}public

static

boolean

arraystringsareequal

(string[

] word1, string[

] word2)

for(

int i =

0; i < word2.length; i++)if

(a.equals

(b))

else

}}

連線兩個字串

include include void main char lianjie char a 30 char b 30 原型 extern char strcat char dest,char src 用法 include 功能 把src所指字串新增到dest結尾處 覆蓋dest結尾處的 0 並新增 ...

交換兩個字串

交換兩個字串,原來的字串分別為 學生 和 好 字串輸出顯示為 學生好 交換後輸出顯示為 好學生 include using namespace std int main char c1 5 學生 char c2 3 好 char m,n,t m c1 n c2 cout 交換前 m n n t co...

兩個字串相乘

先附上一張演算法圖 解釋 123 456 首先拿出1和456相乘,儲存到陣列1 2 3 的位置,然後拿出2和456相乘2 3 4的位置,依次類推,直到第乙個字串遍歷完 然後將他們相加,依次存到陣列中 實現如下 int j 0 int resindex 0 for int i 0 i然後再考慮進製,需...