0 like 0 dislike
6.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) | 6.8k views

44 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<stdlib.h>

int main()

{
* * * * * * **** ** * * am,b,c,i,j,k,l,m,o,p;
*** * ** * * **** * ** ****** * *** * ** *
** *** ** * *** ** *** * * * ***** *
***** * **** * ** **
* * * * * ** ** * * **** *** *
* ** *** * *
* * ** * ** * ** * * * ** * * ** * *** * * * * * * ** * * * ** **
* * * * * * * *** ** *** * * ** * *** * *** ** ** *** ** * * **

** ** * * * * * ** ** **** ** ** ** * * * * **** *** *** * * * ***
** *** ** * * ** ** *** ***** * ** ** * * ** ** *** * **** * * *** ** *
**** * *** ** * ** ** *** ** *** * ** *** * * *** * * * ** ** * ** *************
* * ** **** * * *** ** * **** ** * ** ** * * * ** * * *** ** *** *** * * *** * ** *** ***** * * * * * *** *
* ** **** * * ** * * ** * * * ***** ** * ** * ** *** ** * *** ** ** *** * * * ** ******** ** ** *
*** * ** ** ** ** ** ***** * ** * ******** ***** * * * * ** * ***** * *** * *** * **** ** * * * * *
*** ** ** * *** ** * * ** * * * **** *** * * ** ***** ** * * ******** ** ** ** * * * ** ** ** * ** * ** *** *** * * *
**** ** **** ** * * ** ** * * *** * ***** * * * ** * * * * ***** ** *** *** * * * * * * ****** * ******* *** ** * *
*** ** * * * * ******* *** ** * * ******* ** * ** * ***** * * **** * * * * * * ** **** * ** * ** **** * *
* ** **** * ** * **** * * ****** ** ** * * ****** * **** * **** * *** * * * *** * * *** * ** ** ***** * * * ***** * ** *
** * *** * ** ** * ****** * ***** * ** ** *** *** ** ****** * **** ** ******** ** * * * * * * * * *
****** ** * **** ** * * * * ** * **** ** * * ** ******** ** ****** * * * ** **** * ***** ** * * ; p>=1 ; p=p-1)
** ** * * * **** * * * * * * ** * ** * * ** * * ** * ** *** * * * **** ** **** ** ****** * **** * * * * ** **** * **** * **
* ** ****** **** * * * *** *** * * ** *** ** *** * ** ** * * * ** * *** *** * * **** ** ** *** *** ***** ** ** * * * * * *
*** ** * *** * * * * * * ** * * ** ** * ** * ** * ** ** ****** ** **** ** * ** * ** * * * ***** * * * *
* * ** ** ** * * ** * * * * ** * ** ***** ** ***** ** ***** * *** **** ***** * * * ** * * ** * ***** **** * ****
* ** **** * ** ** * * * ** ** **** ** ** * ****** ** **** * ***
* * ** * * ** * * * ** *
** * * * * ***** * * * **** * * * * *********
** ** * * * * ** * * 0;

 }




** ** * ** *** * *** * * **** * ** * *** * * += c[i].r;






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






* * * **** ** *** ** * ** ** ** ******** += c[i].g;






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






*** **** ******* ** * * *** ****** * * * += c[i].b;






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






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







    






******** **** *** * *** * = sr/n;







    






*** *** * * * ** ** = sg/n;






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






* * *** ** * * ** * = sb/n;






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






* * *** ****** ******* avg;







 







};







 







double brightness(struct Color c)







{







 






* ****** *** * * * * * ** bright;







    






* ** *** ** ** * * = (c.r + c.g + c.b) / 3;







    






* * ****** * * *** * bright;






** * * ** * ***







}







 







void printColor(struct Color *c)







{







    






*** * * ** * * * * * ** ("(%d,%d,%d) * ** ** *** ** * * **** *** ** * **






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







}







 







#endif



安安  說  (23:36):

9753]AC 20161221 exercise 2

[16865]AC 20161102 作業2

[17203]AC 20161109 exercise 1

AC 20161207 exercise 1



quietiest 說  (23:38):

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<ctype.h>



int main()



{
** *** * * * *** i=0,j=0,t;
** * *** * ** ** * ** ch,xh;
* *** ** ** ****** * ** a[100],c[100]={0};
****** * * ** ** ** b[100],d[100];

    
*** ** ** ** ** ****** * ((ch = getchar()) != 32) {

******* ***** **** * *** ***** * ** * ** *** ** * *** = ch;
* * *** * ** * ** *** * * ** *** ** ** ***
*** * ** *** * * *
* ***** **** ** ** ***** * = '\0';

    
* **** * ** *** * ** **** = getchar()) != '\r') {
* * *** * ** **** * * ** * ** ** *** * * * * *** = xh;
* * *** ** *** ** **** ** ** *** * **
** ** * * * * * ** ****
* * * * * * ** * = '\0';

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

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

    


** ** * ** * * * ** * ** * * {
*** ******* ****** *** *** ***** * * * * * *** *** * * * is \"%s\" in \"%s\"",d,c);
* * * *** **** * ** **

    
*** * * * * * * * {
** ********* * *** * ****** * ** * * * ** ***** * *** ** * * ** are no \"%s\" in \"%s\"",d,c);
*** ** * * * * **** *****

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

}
answered by (43 points)
0 like 0 dislike
Hidden content!
int main(void)

{
*** * ** * ** * *prt;
* ** * * *** ***** ** string1[40];
**** ** * * * * * * string2[40];

int i;
* ** *
** *** ** * * * ****** *
*** ** * ** * * ** *



prt= ** * **** * *

if(prt == NULL)
*** ** ****** * ** **** * ***** * are no * **** **** * * in *** *** * ** *** **

else
* * ** ** ** * *** ** * * is * * *** ** * in **** ** * ** * * **





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

#include * **** ****

#define LENGTH 80



int main(void) {
* * ** * * **** * *** z[LENGTH];
*** * ** * * k[LENGTH];


* *** ***** ** * ** ** * ** LENGTH, stdin);
* * * * * * * * * * ** LENGTH, stdin);
* * ** ********* * * ** * - 1] = '\0';


***** * ** *** * * * * *loc = strstr(z,k);


* **** ** * * * *** **** == NULL) {
** *** *** ** **** ** ***** ** * *** *** *** * ** ****** are no %s in ** *
** ** * **** *** ****
** * * * *** * {
** ** * ** * ** **** * ***** * ** * * * * ** * * is %s in * * * * k, z); * * ** * * * * * *** ** ** * * * ** * ** ** *** **** * ****** ** - z
***** * *** ********* **


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

}
answered by (-34 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 %c%s%c",c,s2,c,c,s1,c);

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

** **** ** * * * * *** ** * ****** * * ****** *** is %c%s%c in ** ** * * * **
*** * ** *** ** **** 0;

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

#include **** ***



int main(void){


* ***** * * ****** **** *** * * * **
** * ** * ** * ** i,j,k = 0;


* * ** *** * * ** = '"';


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


* * * * ** ***** ** = 0;i < strlen(a);i++)
** ** * * *** ** * * = a[i];
* * *** * ***** **** = 0;i < strlen(b);i++)
** **** * * ********** * * = b[i];


** * **** * *** * * = 0;i < strlen(a);i++){
***** *** * ***** ** < 97)
* * **** * * * * * * **** = ch[i] + 32;
** ** ** ** *
* ** * ** ** *** ** * = 0;i < strlen(b);i++){
****** * * * ** *** ** < 97)
* ** ** *** * ** ** * * * ** * = dh[i] + 32;
**** ** * * * ***




**** * ** ** * ** * = 0;i < **** * *** *
* * *** *** ** * * = 0;j < strlen(b);j++){
*** ** *** ** *** * ** * ***** *** + j] == dh[j])
* *** * * * * * * ** * * **** ** * ******* ** = k + 1;
* * * * ***** * * * **** *** * * **** ***** ** if(k == strlen(b))
* * * * * ** * * * * * **** * * ***
**** *** * * * ** * * ** * *** ***
** * * * ******* * ****** ** * * * **** ** = 0;
* ** ** **** * * * * * ** ***** *** * * ** *
*** ********* *** ** ** ** *** ** **
** *** * * * *** *
* **** * ** * * * ***** ** * == strlen(b))
** ** * * ** *** * ** *** *** * * **
* **** * ******** **


* * ** * * * * == 0)
* ** ** * * * ** * *** * * ** * are no %c%s%c in * * * * **** **
* ** * * ** * ** *** * if(k == strlen(b))
* *** * * *** ***** * * *** ** *** *** is %c%s%c in * * * *********





 return 0;

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

#include <stdlib.h>

#include <string.h>



int main()

{
* * ** * * * * * * * * a[100],b[100];
** * * * *** ** ** * ** la,lb,i,j,n=0;
******* * ***** **** ***** *** * * **** *
* * * *** ** ** *** *** * ** = strlen(a);
*** * * ** * ** * * = strlen(b);
** **** * **** * * ** ** *** *
*** * * * ** ** * **
* * * * * ** ** ** ** ** * * ***** * * ** * * *** * && a[i]<='Z')
* ** * * * *** *** ***** **** **** * ** **** * ** * * * ** * * = a[i]+32;
*** * ** ** ** * * *
*** * * * * ** ** * ***** ***
* ** *** ** * ** *
*** **** *** * * * **** **** * * * ** *** *** * && b[i]<='Z')
* * **** * ***** ** * *** *** * * **** *** * *** * ***** * ***** **** ** * **** = b[i]+32;
** * ** **** ** ** ***
** *** *** * * * * * *** ** ***** **

    {
***** ** * * ** * * * * * ** ** * * * ******* ***
********** * ******* *** *** ** ** * * * ** * ******* *
** *** ** *** ** ******* ** ** * *** * * * * *
*** * *** *** * ** *** ** * * ** * ** * * ** * * * * **** (a[i]==b[j])
** * * * ** * * * * ** **** ** * * ***** * * ** ** ** **** **** *** **** *** *** * **** ** **
****** ** * *** * ******* **** *** *** * * ** * * * * ****** ** *
** * ** ***** * ******* ** * * * * *** *** * *
** * * *** * * * **** *** * ** * * * ** * *
*** ** ** ** ** * * * ** * *** ** *** ** * *** ** * * ** ** * ** is "%s" in "%s"\n",b,a);
* * * * *** ** * * ** * ** ** * ***
* ** ** * * ** ***** * * * * *** * ** * ******* ** * ** * * * *** is no "%s" in "%s"\n",b,a);

    }
* * *** * * * ***** *** * * 0;

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

#include ** ** ** * **

#include <ctype.h>



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

int main ()

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


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

}

void test(char *t1,char *t2)

{
* * * * * **** * * * b1[30],b2[30];
* ** * ** ** **** * * *** i ;
* * ** * * ** ** (i=0; i<30; i++)
* * **** ** ** * *
**** * *** * ************ ** *** * ** * ** * ***** *
* ** ** ** * **** * *** **** ** ***** *** * * *
* ****** * * *


* **** *** * * * * * * * (i=0; i<30; i++)
** ** ** *** ** *** *
* *** * * * ** * * * * * * * * * * ** * = toupper(t1[i]);
* * * * ***** * ** * **** *** = toupper(t2[i]);
** * ** *** * * ***


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



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

#include ** * ** *



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

int main ()

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


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

}

void test(char *t1,char *t2)

{
* * ** * * * *** b1[30],b2[30];
** ** * * * ** ** ** * i ;
****** * * ** ** * * * (i=0; i<30; i++)
* * ******** **
** * *** ** * * **** ** * * ***** * * * * * ** *
* ** ** ** ** * ** ** * * * * ** ******
** * * ***** ** ** **


* ** * * ****** ** ****** (i=0; i<30; i++)
* *** * * * * **** *
**** ** * ** ** * ************ ** ***** * * * = toupper(t1[i]);
* ********* ** * * ** * ** *** ** *** * * ** *** = toupper(t2[i]);
* * * * *** ** **** *


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



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

#include * *** *



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

int main ()

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


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

}

void test(char *t1,char *t2)

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

}
answered by (-162 points)
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)

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

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