0 like 0 dislike
6.7k views
子字串

請設計一個程式,使用者會輸入兩個字串,兩個字串間用一個空格隔開,每個字串的內容只會包含大小寫的英文字母,請判斷第二個字串是否出現在第一個字串內。請將大小寫視為同一個字。

輸入範例1:

friEND end

輸出範例1:

There is "end" in "friEND"

輸入範例2:

friEND friends

輸出範例2:

There are no "friends" in "friEND"
asked in 2016-1 程式設計(一)AC by (18k points) | 6.7k views

44 Answers

0 like 0 dislike
Hidden content!
#include * ** ** ***

#include * * *

#include * ** * *



int * ***
****** **** * * * ** * **
* * *** *** ** ** * ** ** ** *** ** ***** *
**** * *** ***** ** * * *
* ** ** * ******* *** * ** ** * * //定義

*** * * **** ** *
* ***** *** * * * ***** * * ** **** ******
*** * ** * * * ******
** *** * * * ** * ** ***** (i = 0;s[i] != ** * **
* ** * * * **** ***** * ***** *

* ** ** * ** * * * sizes ++;
* * *** *** * * ** * **** ** ***** * * *

* ** ***** * }
* * * * *** * * ***
* ** * * * * (i = 0;t[i] != * * *
* * * * * *
* ** * * * * ** * *** * ** * sizet ++;
** ** * * * *** *
** ** **** }


** * * * * * ** * **** * *** * * **** ** *

* * *** ** *** *****
** ** for (i = 0;i < ** * **
*** * ** * * *

* * ** * **** * *** * p[i] = s[i];
**** ****** * * *****

** *** }


** * * ** for (i = 0;i < *
* * * ** *** *** ** **

*** * * * * ** *** * f[i] = t[i];
* * ** * ** ** ** *

* *** }
* *** ** *** *** * ***
* * * for (i = 0;i < ** ***
* ** *******

{
** ***** * ***

* *** ** * if (p[i] >= 'a')
* * ** **

* ***       p2[i] = p[i] - 32;
* **   * * *** ** ****

* *** else
**** * **** * *

*       p2[i] = p[i];
***  

}


** *   for (i = 0;i < sizet;i++)
** **** *  

{
* * ** * ****

*** * * * if (f[i] >= 'a')
*** ** * *

** *** * *** *** *** ***** f2[i] = f[i] - 32;
* * *** *** * ** **

** * * * ** else

*** **** * * *

** * ** * **** **** * * f2[i] = f[i];
* ** *

}


* * * * for (i = 0;i < ** *


** *** * ** {


** * * * ** ** * * * * * * *** * if (p2[i] == f2[0])


*** ** * ** * * ** ** ** *** ** ****** {
* * *** *** *** * ** * * * *** ** *** *

* * * ** * **** * ** * ** ** ** ** * ** * * ** j = i;


* ** * ** *** ***** * * ** * * ** ** * *** * for (u = 0;u < *


** * * * * ****** ** *** * *** * * ***** {


** * * * ** ** * **** * ** * * * * ** * ***** ** * *** * if (p2[j+u] == f2[u])
* * ** ** ** ** ** * ** ** ** * **** ** * * * ** * * * *

** * * ** * *** ** * * ** ** * * *** * * *** ** * * * {
** ** ** * ** * **** **** *** ** * * ** * *** * * * * * * * ** *

** * * * * * ** * ***** ** *** ** *** * * * *** *** * ** d += 1;
* * * ** * * **** * * ** * ** ** ** * ** ** * ** * ** * *** * ***** **

** *** * ** * *** * * *** * * * * * * * ** ** ** * * * *** * * * *
* * *** * *** * * ** **** ** *** * ***** * * ** *** * ** *** *  

* *** * * ** ** * * * * ** **** * ** ** * * ** else
** * * * * * * ** * ** ** ** * * ** **

*** * * * *** * * ** * ** * ** * * * * {
* * ** * * * * * * * ** ** *** * * ** * * * * *

*** * *** * ** * * * * **** * * * ** ** * ****** *** * ** ** d = 0;
** ** ** *** ******* **** ** * * * ** **** ** *        

                  *** ***   break;
******       * * * ** * * * ** **** * * *

* * * * *** ** * ***** * *** * *** * ** * **** }
* * ** * * ** * * * * * * * * * ** ** * * * * ** ** ** **

*** * * * ** ** * * * ** * * * * *** ** * ** }


** * ** ****** * ***** * *** ** *** * * * }


* * * *** }


* * *** * *** ** * (d > 0)
** * * * * * * * ** * * ** **** **** ****** *** *** * ** *** * * * *** ********
** * *** * *** * *** * * * * * is %c%s%c in ** ** * *** **
** * * * * **** * **** *** ** ** * * * *** * * ** ** * * * * ** * **** * * ** ** * * ** ** * * *** **
** * * * * * * *** ** *

*** * * * ****
** ** ***** ** *** **** ******* are no %c%s%c in *** * ****** **
* **** *** * * **
* ***** ** ** * ** * * * 0;
* * ** * * *** ***

}
answered by (-157 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main(void){
* * * * * * ** ****
* *** *** * *** * * s[100],t[10];    
***** * * * * * * *
* *** * * * ** ** ** ** ** ** ** * ** *** **
** * **** * ****** *** ** **
* * * *** * ** ****** i,j,sizes,sizet,d=0,u;
* * * **** ** ** ** * *
* * *** * * * ** ** = sizeof(s);
* * * * * ** *
* * * * ** * ** * (i = 0;i < sizes;i++)

{
* *** * **** * ****** *
* * * ** * * * * (u = 0;u < sizet;u++){
*** * * * * ** *****
****** ** * *** *** ***** (t[u] == s[i] || t[u]-32 == s[i] ||t[u]+32 == s[i])

* **** * * ** *** *
* * * *
* ** * * ***** ** * * (j = i;j < i+sizet;j++)
** *** * ** * **** *


** * **** * * ** ** ** *** * *** * * ** * ***** (s[j] == t[j])
* *** *** * ** * ** **** ** ** ** * *** *
*** * ** ****** * * **** * ***
* * ***** * ******* ***** * ** * **** **** *
*** ** * ** *** ** * * *
*** ***** ** ** * ***

}



}



}
* ** ** **** *
* ** * *** * * * * ***** (d / 3 != 0)
**** * *** * ***
*** * *** * *
** ***** * ** * ***** * * * ** ********* *
* * ** ** * **** ** * * * ** ** is %c%s%c in *** *** * * ****    
*** *** * * *** ** ** * ***** * *** * * *
******* * * * ** *    
* **** ** * **** * * ** *
* * * * ** ** * * * ***

* ****** ** * ***
* ***** ** * ** * * ***** ** * are no %c%s%c in * * * **** * *
* ** * * * * * *
* * * ** * * * * * *** * 0;

}
answered by (-157 points)
0 like 0 dislike
Hidden content!
* * *** ** ** **
* * * * ** *


* * ** * *
**** *** * **

** * ** * char ** * ** *** *

**** *

* ** *** * * * *
* * **

** * * int * ** **** ** **
** * **

* * * * * * = *** *
*** * ****

******* * * ** for (i = 0;i *** *

{
* * * * **

** * *** ** for (u = 0;u ** * *
* * * *

* * * ** if ** * == s[i] || * == s[i] * == *

** ** * * * * {
** *** * * *

* * ** ** for (j = i;j ** * * *
*** ** ** {


** * ** ** * * * if * * ==
* * * * *** *** *

* ** ** **** * *** **
* * * * * ** * *** **

** * ** }
* * ** * * ***

}



}



}
*** * ** * *

*** ** * if (d / 3 != 0)
***** * *

* * * *** {
*** * **** * **

* * *** * * ** ** * is %s in * ***** * ** ** *

**** * ** ** * * ***** *

* ** ** * ** ***

** ** **

* ** * **** * else

* * *** *

*** ** * * * * are no %s in * * * **
** *

* ** * ** * 0;

}
answered by (-157 points)
0 like 0 dislike
Hidden content!
//  Created by HoMingJui on 2016/11/3.

//



#include <stdio.h>

#include <stdlib.h>

#include <ctype.h>

#include <string.h>





int main(){
*** ** *** ** **** a[100],b[100],x[100],y[100];
** * ** * ** * ******** i;
* ** ** ** * *** **** ** ** * %s",a,b);
** * * * * ** * ** * **** ** ******
**** ***** ** * ** *** * * **** ** * ** * ******* ****
***** ****** ** **** * *** * * * * * *
* *** * * * * ** * *
* *** ** ****** *** ******** ***
* ** ** * ***** * ** ** * **** * ** **** ** *
* *** * ** * ****** ** ** *** * * ***** ** ** * ** ** *** *
* ******* ** * **** ** * **** **** * * *
** * *** **** * ** * ** * * * ** * *** ** * ** **
**** * * * ***** ** *
* *** * * *** * * * * ** * **
***** * * ** * ** *** ** ** *** ** *** *
* ** ****** * ** * ** ** * * *** ** * ** ** * * ****** ** ** * *
**** ** * ** ** **** * * * * * ** * * ******
*** *** * ***** **** * ***** ** * ** *** * * ** *** *** * *
***** * ** *** ****** * ****
***** **** * *** *** * * * *** ***
** ** *** * * ** * * * * **** * ** * is \"%s\" in \"%s\"",b,a);
* * * *** * * ** *
* * * * * * ** ** **** **
** **** ** * * * * * **** * **** * ***** * ** * are no \"%s\" in \"%s\"",b,a);
** * * * ** ** ** * **
* * ** *** *** *** ** * 0;

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

Related questions

0 like 0 dislike
0 answers
[Resource] asked Dec 7, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 18872 - Available when: Unlimited - Due to: Unlimited
| 46 views
0 like 0 dislike
10 answers
[Exercise] Essay (Open question) - asked Dec 7, 2016 in 作業 by Shun-Po (18k points)
ID: 18876 - Available when: Unlimited - Due to: Unlimited
| 2.1k views
0 like 0 dislike
0 answers
[Resource] asked Dec 31, 2016 in 2016-1 程式設計(一)AC by laich (937 points)
ID: 20298 - Available when: Unlimited - Due to: Unlimited
| 38 views
1 like 0 dislike
102 answers
[Exercise] Coding (C) - asked Oct 27, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 15378 - Available when: 2016-10-27 18:30:00 - Due to: 2016-10-27 21:00:00
| 13.4k views
0 like 0 dislike
39 answers
[Normal] Coding (C) - asked Oct 11, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 13020 - Available when: Unlimited - Due to: Unlimited
| 6.8k views
12,783 questions
183,442 answers
172,219 comments
4,824 users