Toggle navigation
Courses
Questions
Tags
Users
AC 字串 練習題 搜尋
0
like
0
dislike
1.1k
views
請設計一個程式,使用者會輸入兩個字串,請搜尋第一個字串當中第二個字串出現幾次。
輸入說明:使用者會輸入兩個字串,兩個字串接用雙引號("")包起來,兩個雙引號間會用一個空白隔開。
輸出說明:請輸出第二個字串在第一個字串中出現幾次。
輸入範例:
"The racing car was clocked at 160 miles p.h. " "a"
輸出範例:
4
asked
Dec 7, 2016
in
2016-1 程式設計(一)AC
by
Shun-Po
(
18k
points)
|
1.1k
views
answer
comment
Please
log in
or
register
to add a comment.
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
Add answer
Cancel
24
Answers
0
like
0
dislike
Hidden content!#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char q[100],a[100],b[100];
int i=1,j,la,l,k,m=0,t,y,o,p=0;
* ** ** * * ** ** ** * ** * * *** * ** ** **** *
l = strlen(q);
* * ** * * ** **** * * ** * * * * *
{
** * ** * * ** *** * ** * *** ** * ** ** * ***** * * ** = q[i];
* * * ** * * * * ** * * ** ** ** ** ** **** *** * i+1;
}
la =i-1;
k = i+3;
* * ** **** * * * *** ** * **** * **
{
* * *** * ** ** * * ** * ** * ** * ** ** = q[k];
***** ** ** ** * * * ** * ** * * * * **** * ** * * * * **
* * * * ** * * * * * * ** ** ** ** * ** * * *** * * *
}
a[la]='\0';
b[m]='\0';
* **** * *** * ** * * * * *
{
*** * ** **** * * * * * ** ** * * * * * ** * * * temp;