[問題] 鋼彈 我懷疑是電腦有問題還是我有問題

看板b97902HW作者 (Yuan)時間15年前 (2008/10/23 19:55), 編輯推噓2(203)
留言5則, 4人參與, 最新討論串1/2 (看更多)
code 有點長 請見諒 char input1[53] ; char input2[53] ; char s1[53] ; char s2[53] ; int lenth1 ; int lenth2 ; int situation = 0 ; scanf("%s",input1) ; scanf("%s",input2) ; lenth1 = strlen(input1) ; lenth2 = strlen(input2) ; for(int i = 0 ; i<=lenth1-1 ;i++) { s1[i]= input1[lenth1-1-i] ; } for(int i = 0 ; i<=lenth2-1 ; i++) { s2[i] = input2[lenth2-1-i]; } if(strcmp(input1,s1)==0) { situation = situation +1 ; } if(strcmp(input2,s2)==0) { situation = situation +2; } printf("%d\n",situation ) ; 我自己在丟測資時 丟22.22 1.1 出來是 3 嗯 很好 但我丟 1.1 22.22 出來是 1 我覺得我沒打錯啊........檢查好多遍了還是一樣 有人可以幫我解答一下嗎 ? ※ 編輯: ewan7954 來自: 140.112.241.73 (10/23 20:00)

10/23 20:03, , 1F
使用字串函式時請確認字串結尾 ...
10/23 20:03, 1F

10/23 20:03, , 2F
你沒讓字串有結尾
10/23 20:03, 2F

10/23 20:04, , 3F
哇那是什麼函式 @@!
10/23 20:04, 3F

10/23 20:44, , 4F
多謝各位的解答 不過我想問 為啥第一個沒加可以過
10/23 20:44, 4F

10/23 20:45, , 5F
第二個沒加結尾就錯
10/23 20:45, 5F
文章代碼(AID): #1906ONPN (b97902HW)
文章代碼(AID): #1906ONPN (b97902HW)