0 like 0 dislike
4.8k 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) | 4.8k views

44 Answers

0 like 0 dislike
Hidden content!
** * * * *
* ** ******
*** * ** ******
********* * * * *



int main ( void )

{
** * * char **** ** * *
* * * **   char * *

** * * ** * ** * ***** i,j;
*** * *** * * ** *
*** * ** ** ** **** *** * ** *
* * ** ** * * * * *** * ***
* * * ** * **

** ** * * * ** *** **
** * {
* ** ** *** ***** * ** c1 = a[i];
*** **** * * *** c1 = * * *
** **** * * *** ** ** * * d[i] = c1;
***   }
* ** *  

  *** ** * * * *
* * **** * * {
* * * * * **** * **** c2 = b[j];
* * ** ** ** * * *** * * c2 = *** * *
** * ** *** * * e[j] = c2;
* * ** * ** }
**** *

** ** ptr = * ***
*** ** *

** * * ** * *
****** ** * * ** * ** ** * **** ***** are no %c%s%C in * * *** *** *
** *** **** * **** **

*** * * ** else
* * * * ** * **** * ** **** * is %c%s%C in * ** ******** *
****** ** * return 0;

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



int main ( void )

{
**   char ************ ***
** ** * * ** * char ****

* * *** *** * * ** ****** i,j;
* ** *** ** * * * **
* **** * * * * ** **** ** * *
*** * **

    * * ****** **
** * * ** {
****** **** * * * * * ** c1 = d[i];
* *** ** *** * c1 = * *** **
** *** ** * * ** **** d[i] = c1;
* **** *** ** * }
** * * *

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

** *** * * * * ***** * *** **
******** ** * {
* ** * ** *** *** * c2 = e[j];
***** ** * * ** *** ** ** * c2 = **** *
*** ** ** * ** **** e[j] = c2;
** * * * }
** ** ** *

** ** * ** ptr = ****
** **

*** *** *** * * **
* * * **** * * * ***** * * * are no %c%s%C in ** ** ****
**** ** * ** * * * **

*** * * * else
* ** * ** ** * **** * * *** * is %c%s%C in **** * ** *
* * ** ** * return 0;

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

#include <string.h>

#include <ctype.h>

#include <stdlib.h>

int main()

{
** ** *** ** ** * * * *** * **** * * * **
** **** **** ** ** * * *second_find,number;
* ***** * * ** *** * * * first_search[99],second_search[99];
* ** **** ** ***** * * i;
* ** * * ** * * *** ** * *
* * *** **** ** * ** **** ** **** * **** * ** ** *****
* * * * * * *** * * * * * * **
* * * ** * ** ** ** ** **
* * * * ** ** ** ** * ** **** *
* ** *** * * * * ** *** ** *** * ** ** *
* * **** * ** * * * * * * * * ** * **
** * ** * * * **** * ****
*** ** * ** * * * * **** ** ** = * *** *** * *
**** * * *** * (second_find==NULL)
** * * * * *** * ** * ** ** *** ** are no %c%s%c in ****** ***** * * ** **** ********
* * * *** * **
** ** **** * *** ** * is %c%s%c in ***** * * * * *** * *** * * * *


******* * **** *** * 0;
* ** *** ** *** * **
* * * ** * * ** *** *
answered by (-122 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include ** * ***

#include <ctype.h>

int main()

{
* * * * ** * * * * * * **** **** * ******* ******* *
* * * ** ** * * *second_find,number;
* ***** * * * ****** **
* ** ** ** ** *** *** * * ** * * *** *** *
**** * ***** * ***** ** * *** * * ***
* ** * * *** * * * *** **** ** ***
* * ** *** * * ****** * * = strstr(chang_first, chang_second);
***** * * *** ** ** **** (second_find==NULL)
* * * * * ** *** ** ***** are no %c%s%c in *** * *** **** ** * * ** ****
** * *** * ** * * ****
**** * * ** * * *** **** * * is %c%s%c in * * * * * * * * ** ** *


** ** * * * * * * * ** ** 0;
*** *** * * *
*** **** * ** *
answered by (-122 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<string.h>

#include<ctype.h>



int main ( void )

{

* * *** * ***** ** * ***** ** i,j;

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

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

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

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

* * * ** * ** * * * * * * * * ** * ****** ** * = s1[i];

** ** ** ****** ****** * **** * * ** * * ** = tolower(c1);

* * * ** ** * ***** *** * ** ** * * * * * = c1;

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

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

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

***** * * * ** ** ** **** ** = s2[j];

***** *** * ****** **** **** * * *** * * = tolower(c2);

********* * * ** *** *** * ** ** ** *** * = c2;

** ** * * * ** ****
***** * ** ** * * * * * = strstr(a,b);

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

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

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

* * * * ** * *** ** * * * **** **** * * ** ** * *** * * is %c%s%c in %c%s%c",c,s2,c,c,s1,c);
* * * * ***** * * * ** * 0;

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

#include<string.h>

#include<ctype.h>



int main ( void )

{

* ** * *** * ******* i,j;

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

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

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

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

** * * ** * * ***** * * *** * ** ** * = s1[i];

** * *** ** **** * * ** * ** * * * **** *** = tolower(c1);

*** * *** * ****** * * * *** *** * ** ** = c1;

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

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

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

* *** * * **** *** * ** ****** * * * * = s2[j];

** ** ******* * * * * **** * ** * ** = tolower(c2);

** * * ** * **** ** *** *** ***** ** **** * * = c2;

* ** * ** * * * ** *
** * * **** * ** * * * * = strstr(a,b);

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

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

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

** * * ****** * ** *** **** ** * ** *** ** * ** ******* *** is %c%s%c in %c%s%c",c,s2,c,c,s1,c);
* * ***** * * * * * * *** ** 0;

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

** *** ***

#include<ctype.h>



int main ( void )

{

* *** * * *** * ** * i,j;

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

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

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

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

* * ** * * * *** * **** * * *** **** ** ** * = s1[i];

* * * ** * ** * *** *** ******* * * * = tolower(c1);

* ** * * * **** * * ** * ** ** * = c1;

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

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

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

** * ** * * **** **** ** *** *** * = s2[j];

** ** ** ** *** * * ** * * ** * * = tolower(c2);

*** * ** * ** * * *** **** * * * = c2;

** ** * ***** ******* *** *
* * ** ***** ** ** * = strstr(a,b);

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

**** * ** *** * * *** * * *** ** * ** ** * ***** are no %c%s%c in %c%s%c",c,b,c,c,a,c);

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

** *** * ** ** * * *** **** **** ***** * *** * * ** * ** *** is %c%s%c in %c%s%c",c,b,c,c,a,c);
***** * ***** * * ** 0;

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

#include<string.h>

#include<ctype.h>



int main ( void )

{

* * * * **** **** i,j;

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

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

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

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

* ** * * *** * * * ** ** ** * ** = s1[i];

** ** * *** * * * ***** * **** **** = tolower(c1);

* * * ** **** ***** *** ** * ** * ***** **** * * ** = c1;

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

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

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

****** ** *** * * * **** * ** * * * ** ** * ****** * = s2[j];

* *** ** ***** **** ** * ******* * *** * = tolower(c2);

* * * *** * * * ** * ***** ** * ** *** = c2;

* ** ******* ******
* ** ***** *** * = strstr(a,b);

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

* **** * * ** ** ***** ** * * * * * ** * * *** are no %s in %s",b,a);

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

*** **** ** *** * * * *** * ** ** * ** * ** * * ** ** **** is %s in %s",b,a);
** ** * * * **** * ** 0;

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

#include<string.h>

#include<ctype.h>



int main ( void )

{

* * * * *** ** i,j;

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

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

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

* ** * * * * ***

*** **** * *** * *** ** ** * ** ** *** * ** = s1[i];

* * ***** ** * *** * ** ** * * * ** * = tolower(c1);

* * * * * ** * ** ** * *** ** * * ****** ***** = c1;

** * *** *** *

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

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

* ** ** ****** * ** *** * * **** ** = s2[j];

** **** * * * * **** * ** * ** * ** = tolower(c2);

* * * *** ** *** ** * * *********** * ** = c2;

* ** ** ** ** * * *
** ** * * * ** = strstr(a,b);

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

* * *** * * ** * * ** * * *** * ** ** * are no %s in %s",b,a);

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

** * * *** *** ** *** * ** * *** * ** * ** ** * is %s in %s",b,a);
* * * * * * * ** ** * ** 0;

}
answered by (-102 points)
0 like 0 dislike
Hidden content!
#include ** **** ***

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

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

#include * * *

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



int main(void){

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

***** * * * ** ** * ** *
* * *** * * * * ** * *** *** * * * *
* * *** *** * * * ** * *
** ** *** ***** ******* (i = 0;s[i] != '\0';i++)

 
** *
* *** **
* ***** * ** ** * **** ** * * **** * ++;
** * * * * ***** *** * ** ** *

 }


** * ** ** ** * *** * *** ** (i = 0;t[i] != '\0';i++)

 
* ** * *
* * * ** * ** *** * *** *
* **** ** ++;
* ** ******

 }

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

**** * * ** **** ** **
* * * (i = 0;i <= sizes;i++)

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

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

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

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

 
* * ** (i = 0;i <= sizes;i++)

 

{
* * **
** * * * *

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

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



}


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



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



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

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

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

}


* * * **



//asplpSLP slp


* * (i = 0;p2[i] != '\0';i++)

 
* * ***

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


* * * * ** * **
* **** * * *** ** ***
* ** * ***** ** = i;
** *** * *** ** *
* **** * *** ** * ** * * (u = 0;u < sizet;u++)
*** **** * ** **
* * ** **** * *** * *****
** *** ** * * * * *** ***
*** * ** ** ** * * *** ** (p2[j+u] == f2[u])
***** ** ** ** *** * ** * ** ** *
**** ** * ** ** * *** ** ** += 1;
* **** ** * *** **** ** ***
* ** **** * *** * ***** * *** * **
* * * * ** ***** ** * * ***
** * *** ** **** * * * *
*** *** ** ** * * ** * *** *
*** * ***** * ** * ** * = 0;
* * ** *** * **** ** **** ** *** * *
** ** ** * * * ** ** ***** * **
** ** ** **** ** * * * *
* * * ************** * *
** * * ** * *** * *** * **** ***
* * *** ** * *****
** ***** * ** **** ** **
* * * *** * **
* * * * ** ****
* * * *

 
*** * *** * ** ** ** * * (d > 0)
** *** * * ** ** * ***
** * **** ** * ** ** **** * * * * is * ***** * * in ** * * *** ****
* ** ***** * * * * ** ** * *
* * ** ** * ***** * *

** ** * ** **
* * **** * ** ** ** * * * *** * * are no * * * * * * in **** * * * * ** * **


** *** * *** * * ** 0;
* * ** * * * ** ** *

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

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
| 1.7k 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
| 9.9k 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
| 5k views
12,783 questions
183,442 answers
172,219 comments
4,824 users