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

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

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

輸入範例:

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

輸出範例:

4
asked in 2016-1 程式設計(一)AD by (18k points) | 188 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)
Get it on Google Play Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.68.65.22
©2016-2020

No related questions found

10,964 questions
126,603 answers
124,036 comments
3,820 users