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

44 Answers

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

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



void test(char *t1,char *t2);

int main ()

{
* ** * *** * * ** *** * s1[10],s2[10];


*** ** ** *** * * * *** * ****** ** != EOF)
** ** ** * *** ** * ** * * ** ** ******** ** ** ** *** ** ** * * ** ** != EOF)
** ** *** * * ********* ** * **** *** ** ** ***** ***** *** ** * ** ** *

}

void test(char *t1,char *t2)

{
** **** ***** *** * **** * * * ** = toupper(t1);
** * * * ** ** * ** * = toupper(t2);
**** ** * ** * * * ** *loc = strstr(t1,t2);
* * ** *** *** ** == NULL)
***** ** ** * * * *
* * * * ** ** ** *** *** *** * ***** * * * * **** is %s in ** * * *
** ** * * * * ***
** * ** ****** *** * *** * *
* **** *** **** * ***
** * ** *** ** * ***** * ** * **** * *** ***** * are no %s in * * * * *
* *** **** ** ** * *

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

#include ** * * *****



int main ()

{
*** * * ***** **** * * * i;
** * ** * * * * * ** s1[10],s2[10];


* * *** * * * * *** * **** * * **** != EOF)
******* ** **** * * *** **** * *** * ** * * * ***** * * != EOF)
** * ** ** *** * * ** *** ** * * *** ********* * * *** * * * * ** **** *

}

void test(char *t1,char *t2)

{
*** * * ** ** *** = toupper(t1);
* *** ** * * ** * = toupper(t2);
**** *** * * * * *loc = strstr(t1,t2);
** **** ** *** ** * * *** * == NULL)
* * ** * * ***
** ** ** * * ** *** ** *** *** ** * * * ** is %s in %s",t2,t1);
** * * ** * ** * *
* * * * * ** * * ** *** *
***** ** **** ** * *
* *** ** *** ** *** *** **** * * ** * ***** * ** ** are no %s in %s",t2,t1);
* **** * ** *** * ***** **

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

#include<stdlib.h>

#include<string.h>

#include <ctype.h>

int main(void)

{
* * ** ** * * * *** * ** * word[100];
** * * ** *** ** ** *** * wordchange[100];
* ****** ****** **** *** word2[100];
* * * * ** *** ** * *** * * word2change[100];
** * *** *** * * ****** i;  
******* * ** ** ** * ** * * * **
*** ****** *** * **** * ***** * ** **
* *** * *** * * * * ** ** ** ** *** **** * *** * ** *** *
* * **** *** ** ** ** **** * * ** ** ** * *
* ** ** ** ***** * * *** ******** * ** * ** ********* ** **** *** * * * ***
** ** ****** * * ** * * * * * ** *** *** ***

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

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



* * * ** **** ** ( strstr(wordchange,word2change) )
* *** * * ** ** ** * ** * * ** * is \"%s\" in \"%s\" ",word2,word);
** * * * * * * * * ** *
********* *** *** ** *** * ******** * * * * * are no \"%s\" in \"%s\" ",word2,word);

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

#include<stdlib.h>

#include<string.h>

#include <ctype.h>

int main(void)

{
** * * * * **** ** * ** word[100];
* **** *** ****** ****** wordchange[100];
* ****** ** * ** * *** * word2[100];
* *** ** * ***** * ***** word2change[100];
** * ** * *** ** * *** ******* i;  
******** ** * ** **** * * *** * *
** *** ** ***** * ** ** ** ***** * * ** ** ** *
*** ** ** * * ****** * * * * ** * **** ** * * * *
* * ** ** *** * * ** **** **** * ***** * ** * ** * * **
**** ** * *** * * ****** ** * * **** *** * **** * * * ** ** * * * ** **** *
* * * * * ** * **** * ** *** *** * ** * **

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

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



** **** * * * * ( strstr(wordchange,word2change) )
** * * * *** * * ** * * *** ** *** ** * * * * * ** ** is \"%s\" in \"%s\" ",word2,word);
** * * * ** * * * * ** *
*** *** * * ** *** * *** * ****** * **** ** *** **** ** are no \"%s\" in \"%s\" ",word2,word);

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

int main(void)

{
* *** *** ** ** *** * ** word[100];
* ******* ** *** * * * word2[100];
** * ** * * * **** * * * ** *
** * * *** * * ** * *** ** *** *
*** *** **** * *** *** ( strstr(word,word2) )
* ** ** *** * **** *** ** ** ** * ** *** ** ** * is ** * **** * in ** * *** *** ",word2,word);
*** **** ** * *** * * **
* * *** ** ** * ** *** * ** *** **** ****** ** * ** are no * * ** * in ** *** * * ",word2,word);

}
answered by (-124 points)
0 like 0 dislike
Hidden content!
#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 (-82 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>
* ****** * ** **
* ** * *** ** **





int main(){
* * ** * ** * a[80], b[80], c[80], d[80];
* * * ***** ** * *** *i;
* *** * *** ** * * ** m, n;
* * * **** * *** ** *** * a, b);
** * * * *** * ***** ** ** %s\n", a, b);
** *** ** ** = 0; m < 80; m++){
* * * * ** **** ** ** *** * * * * **** *
** ** ** * ** *** ***** *** * ** * * ** * * = tolower(a[m]);
* ** ** **** * * *** * * **
*** * * *** ** * ** * ** ** *** * ** * * = a[m];
** * * * ***
* * * * ** * * * = 0; n < 80; n++){
* * ** ** ** * ** ** *** *** *** * ***** ** *** *
**** * * * * * **** ** **** * * ** *** ** ** = tolower(b[n]);
* ***** *** ***** *** * ** * * *
*** * ** *** *** **** *** **** ** *** * * ** * * * = b[n];
* * ** * ** *
* * * ** ** * *** = strstr(c, d);
* * **** * ** ** * ** **** ** i);
** * * * * * * != NULL)
* ***** * * ** * * *** ***** * ** * ** * * ** *** * * is \"%s\" in * ** ** ** **** ** b, a);
*** * * * ** *****
* *** ** * ** * * ** ** ** **** ** are no \"%s\" in * * ** *** ** b, a);

return 0;

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





int main(){
** ** * * * * * a[80], b[80], c[80], d[80];
** * * **** * * * *i;
* * **** * * *** ** * m, n;
*** * ****** *** **** *** * ** * a, b);
** *** ** * * * * *** %s\n", a, b);
** * * * * ** *** * ***** = 0; m < 80; m++){
*** * * * * ** * * * * * * * ** **
* *** *** * ** *** * * * * ** **** * *** * = tolower(a[m]);
* ** ** *** *** ** * ****** **
* * *** ** * ** * * ** ***** * * * * = a[m];
* ** * ***** * * *** *
*** *** * * * * * * = 0; n < 80; n++){
* * *** **** ** *** *** ** * * * * **** *
* ** * ** ** ** * *** * * * * **** *** * ****** = tolower(b[n]);
***** * ** * ** * ********* * * *
* * * ** * * *** ***** * *** ** ** ********* * = b[n];
**** * ** *
** * * * *** * * ** = strstr(c, d);
**** * ** * * * ** * *** ** ** * ** i);
* ** *** * * * * != NULL)
* * * *** * ** * * * ***** ** *** ** ** is\"%s\" in * ** * ** * ****** * b, a);
* * ** * ** * ** *
**** * * * * ** * * * **** * *** ** * ** are no\"%s\" in *** ******* ** * * b, a);

return 0;

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





int main(){
** ** ** * * a[80], b[80], c[80], d[80];
* * *** ***** ** ** *i;
* * *** * ***** * m, n;
* * * *** ** **** * ** *** * a, b);
* * ******* ** ** * *** ** %s\n", a, b);
* * * ** **** * * = 0; m < 80; m++){
* * ** *** ** ** *** ** ** * * *****
* ** *** ** ** ** *** * ** * * * **** *** * * = tolower(a[m]);
* *** ** * * * * **** ****
** *** * ** *** *** * ** * * **** ** ** ***** **** ******* * = a[m];
* ** *** ** **
* * * * ****** *** = 0; n < 80; n++){
****** ** ** ** * ***** * *** **** * * ** **** * *
** *** * ****** * ** *** * * * * * ** ** ** * * * ** ** = tolower(b[n]);
**** * * * * ** * *** ** **
** ** * * ** * * * ***** * * * * ** **** **** ** = b[n];
* * ** **** * *** **
** * *** ** * = strstr(c, d);
* **** * **** **** * * * * * * * i);
* * ** * * *** != NULL)
* * * ** * ****** * * ** *** ** * ** ** * * * is\"%s\" in * * * ** * ** * b, a);
*** * * * * **** *
** * ** * * * ** ** * ******* * ** * * * are no\"%s\" in *** * * *** * * *** * b, a);

return 0;

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



int main(){
** * *** * ** ***** a[80], b[80];
** * * *** ***** *i;
** ** ** ***** * *** * *** ** * ** a, b);
* * * * *** *** *** ** * * * %s\n", a, b);
**** * ** * **** ** = strstr(a, b);
***** ******* ** **** * * * * * ** i);
* * * ** != NULL)
* *** * * ** * ****** ** * ** * * ** * * is\"%s\" in * **** * * * **** * b, a);
* *** **** ** *
* * * *** * * * * ** **** * *** *** are ** * * * in ** * * ** * ** * ** b, a);

return 0;

}
answered by (-105 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.130.93
©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.9k 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
| 11.8k 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.1k views
12,783 questions
183,442 answers
172,219 comments
4,824 users