0 like 0 dislike
2.5k views
請設計一個程式,使用者會輸入兩個字串,請搜尋第一個字串當中第二個字串出現幾次。

輸入說明:使用者會輸入兩個字串,兩個字串接用雙引號("")包起來,兩個雙引號間會用一個空白隔開。

輸出說明:請輸出第二個字串在第一個字串中出現幾次。

輸入範例:

"The racing car was clocked at 160 miles p.h. " "a"

輸出範例:

4
asked in 2016-1 程式設計(一)AD by (18k points) | 2.5k views

21 Answers

0 like 0 dislike
Hidden content!
#include <stdio.h>

#include ** **** ** * **



int main(void){
** ** * * * ** ** * i,j,k,len1,len2;
***** *** * * * *** ***** c,c1[50],c2[50];
** * *** * * ** * * ** c1ptr;
* ***** ** **
* * * **** * * * * **** * "
** * * * * * * ** ** = getchar() && c != '"');len1++)
** ** * *** ** ** * ***** ** ** *** ****** * *** = c;
***** * * *** * * ** * ** * * = '\0';
* * * * *** *** **
* ** * * ** * * * *** ** *** ' '
** * *** * **** ***** *
*** * ** * * * * * *** * ** '"'
** *** * * * ** *** **** = getchar() && c != '"');len2++)
** * ** * * ** ** * ** * ** * * * *** * * * ** = c;
* *** * ** ** * *** ** ** = '\0';
** * *** ** **** * *
** ** * * * ** ** * = c1;

***** * * ** ** * = 0;
* * ** *** * ** * ** * * * *** != NULL){
**** * ** * * *** ** * ******* ***** ** * ** **** **
*** ** ** * * * * * ** * * * ** * += len2;
* ** * ** * * ** * *
* ** * ** **** * *** ** *
* * * *** **** * *** ** * ***** * ** ** *
** * * ** *** * *
* ** * ** ** * * * * * 0;

}
answered by (-216 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.130.233
©2016-2025

No related questions found

12,783 questions
183,442 answers
172,219 comments
4,824 users