3 like 0 dislike
3.5k views
小明在一間公司當行政助理,他主要的工作是處理寄給客戶的電子郵件,寄給不同客戶的信件通常內容大致都一樣,只有幾個關鍵字不同而已,請寫一個程式,來幫助小明更輕鬆的完成他的工作。

輸入說明:

輸入會已一個正整數N作為開始,代表有多少個關鍵字要被置換,接下來的N行,每一行會有兩個字串,代表要被置換的關鍵字以及要置換成的新字串,最後是信件的本文,信件的本文會是一個包含空白字元的字串。

輸出說明:

請將新的信件本文完整的輸出在螢幕上。

輸入範例:

2

100 1000

Jack John

Dear Jack, You still owe me $100, pay off please.

輸出範例:

Dear John, you still owe me $1000, pay off please.
[Exercise] Coding (C) - asked in 2017-1 程式設計(一)AD by (18k points)
ID: 34978 - Available when: Unlimited - Due to: Unlimited

edited by | 3.5k views

5 Answers

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


int main()
{
    int n;
    int i,k,len;
    char ** * **** ** ** * ***** * ***** * **** * **** * ** * * **
    char *p;
    int * *** ** *
* * *   **** * ****** ** * ******
** * ** * * **** *** * *
* ** ** ** ** * ** *** * * * * *** ** * ** * * * *
******* **** ** * ** * * * ****** * * *** *
*** * ** * * ** * ** * * * *** ***
* *** ** ** * * ***** * ** * *** * * *** ** * * ** ****** * * * ** * * * ** * ***** **** *
* ** * * * * * * ** * *** * ** **** ****
* ** **** ** ** * * * * ** ****** * ** * * **
* *** * *** * * ***** ** ** * * *** * * ** * * ***** * **
* **       * * ** *
** *       ** **** **
* *       * *** ** *
*** *       ** *
** * ****** **** ****** ** ** *** * ** **** *** * *
* *** *** * * ***** * ** * ****** * * * * **** * * ****** ****** **** * ** ** ** *
*** * ** ** * * ** ** *** * * * *** ** ** * ** ** * * ** * ***** ** **** **** *
* * * *** ** ** * * ** * * ******* * ** ** * *** ***** *** * * * * * * * **
* *** * ** * ** **** *** ******** *** * *** *** *
* * ** ** *** * * * * * ** * **** ** *** ***** ** *** * ** * *******





    }
        return 0;
}
answered by (114 points)
edited by
0 0
Case 0: Wrong output
0 0
Case 0: Wrong output
0 0
prog.c: In function 'main':
prog.c:29:15: warning: null argument where non-null required (argument 1) [-Wnonnull]
             p=strstr(NULL,before[index]);
               ^~~~~~
0 0
Case 0: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
** * * * ** * **** * a;
* * * ** * **** * i,j;
**** *** *** ** *
*** *** *** * * ** * ** * ** * ** *** ** *
** * ***** *** * **
***** ** **** *************** *** * * ***
* ** **** ** ** ** ** *
* * * ***** * * ***** ** ***** * ** * * ** **** ** * * ***
** * ** * * * *** * **** ** *** *** * ***
* **** * ** ** * * ** * * * ** * ** *** ******* * * * ****** *** * b[1000],c[1000];
*** * *** ** ** **** *** * * **** * ** * *** * * **** * * * *** *** * %s",b,c);
* * * * * * ***** ******* *** ** ** * *****
*** *** ****** **
    
* ** * * * ** * ****
* * ** * **** ** * *
* **** * * * * **
    
    
** ** * *** *** * * 0;
}
answered by (236 points)
0 0
prog.c: In function 'main':
prog.c:14:21: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'int *' [-Wformat=]
             scanf("%s %s",b,c);
                     ^
prog.c:14:24: warning: format '%s' expects argument of type 'char *', but argument 3 has type 'int *' [-Wformat=]
             scanf("%s %s",b,c);
                        ^
0 like 0 dislike
Hidden content!
#include <stdio.h>

int main()
{
* * ** * ** * * * ** N,i,a,b,c,*ptr;
* *** * *** **** * * *
*** * ****** * * **** * ** * * **
* ******* * *****
* * *** * * * * *** * *** * **** *
* * * * * ** * * **** ***
* ******** *** * ** *** ** * * * %d",&a,&b);
    }
   
*** * **** *** * *
* ** * ** **** * * ****
****** ** * *** *** * * * *** **
* * ** * **** * * *
** ** ** ** * ** * **** * *****
**** * ** * * * **
** * * ** * ******
* * ** ** ****** * * * ** ****
* * ** * ** **** ** *
** * ** * * * * * * ** * * * %d\n",a,b);
    }
** *** ** *** **** ***
* ** *** **** ** *** 0;
}
answered by (215 points)
edited by
0 0
prog.c:1:1: error: expected identifier or '(' before '.' token
 .
 ^
0 0
Case 0: Wrong output
0 like 0 dislike
Hidden content!
* * *** * ******
* * * ** ** *
int * ** *** ***
{
** * * *** * int i,j;
**** * *   int set=0;
* * * * ** * * ** *** *** *** ** ** * *
* * * ** {
* *     * * * * * ** **** ****
**** * * * * *** * * {
* * ** * **** * ** * **** ** * * ** ***
** * * * ** * * *** *** **** * * * * set++;
* * ** * ** ** * ** ** }
*** * * * * *** ** * * * ** ** * ** *
** * * * * * * set=0;
* * ** * }
* * ** * **** *** *
* * **** *** ** return 1;
* * ** * * else
***** * *** return 0;
}

int main()
{
** * * ** ** int n;
* *   ** ** **** ****** * * ** * * * *
**** *   {
* ****     ** ** char str[1000];
* **   * ** *   char ** * **
*** **** *** ** * * ** ** ** * * char ** *
*** * * * ** * *   char ***
***** ** *** ** * * ** * char *temp;
* * ** ** * * **** * ** * char *pch;
* * * ** ** * * *** int orilen;
** ** ** ** * * *** *
*** ** * * * * * * * *** **
*** * ** *** * ****
** * * ** ** * ** ** ****
*** ** ** * * ** * * ****** ****
* *** * * * * * **** **
**** * * * ** * * * * * **
** * ** * * * *** * ** ** * {
*** * * * * *** ** * *** * * ***** * pch = * *** ** ***
** * * ** * **** ** * * * ** **** * ** ****** * * **
** ** * * ** * * **** * * *** *
** * * ** ** * * ******* }
* * * ** ** *** *** return 0;
** * ** }
* * *
answered by (160 points)
0 0
prog.c: In function 'main':
prog.c:36:3: warning: 'gets' is deprecated [-Wdeprecated-declarations]
   gets(search);
   ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
prog.c:37:3: warning: 'gets' is deprecated [-Wdeprecated-declarations]
   gets(change);
   ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
prog.c:38:3: warning: 'gets' is deprecated [-Wdeprecated-declarations]
   gets(str);
   ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
/tmp/ccLepvJq.o: In function `main':
prog.c:(.text+0x12a): warning: the `gets' function is dangerous and should not be used.
0 like 0 dislike
Hidden content!
#include * ******* ** *
#include * *** * * ** *

int *** * char str[], const char key[]);

int main()
{
* ** *** ** ** * **** str[1000], key[1000];
*** * * ** * **
* ** ** *** * ***
* * ** ** **** * * * *** %d * * count(str, key));
* ** * ** * ** **** * 0;
}

int count(const char str[], const char key[])
{
******** * ** **** **** * * ***** ***
* * *** * * * ** * * * key);
** **** *** ** *** ** * * * *
** ** * ** ** * ** **
* * * * ** * * * ******* * * ** * *
* * ** * ** ** * * ** ** *** ** * * *** **** *
** **** ** **** * ** * * * * ** * * ****** * * * key);
** ** * * **** ******
**** ** * * *** *** *** * count;
}
answered by (190 points)
0 0
prog.c: In function 'main':
prog.c:9:4: warning: 'gets' is deprecated [-Wdeprecated-declarations]
    gets(str);
    ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
prog.c:10:4: warning: 'gets' is deprecated [-Wdeprecated-declarations]
    gets(key);
    ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
/tmp/cc5PeT7t.o: In function `main':
prog.c:(.text+0x25): warning: the `gets' function is dangerous and should not be used.
0 0
prog.c: In function 'main':
prog.c:9:4: warning: 'gets' is deprecated [-Wdeprecated-declarations]
    gets(str);
    ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:577:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
prog.c:10:4: warning: 'gets' is deprecated [-Wdeprecated-declarations]
    gets(key);
    ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:577:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
/tmp/ccBzifWs.o: In function `main':
prog.c:(.text+0x25): warning: the `gets' function is dangerous and should not be used.
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:162.159.115.9
©2016-2026

Related questions

3 like 0 dislike
6 answers
[Exercise] Coding (C) - asked Nov 30, 2017 in 2017-1 程式設計(一)AD by Shun-Po (18k points)
ID: 34979 - Available when: Unlimited - Due to: Unlimited
| 3.4k views
3 like 0 dislike
14 answers
[Exercise] Multichoice - asked Nov 30, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 34985 - Available when: 2017-11-30 14:00 - Due to: 2017-11-30 14:30
| 2.6k views
3 like 0 dislike
22 answers
[Exercise] Coding (C) - asked Nov 16, 2017 in 2017-1 程式設計(一)AD by Shun-Po (18k points)
ID: 33757 - Available when: Unlimited - Due to: Unlimited
| 9.8k views
2 like 0 dislike
24 answers
[Exercise] Coding (C) - asked Nov 16, 2017 in 2017-1 程式設計(一)AD by Shun-Po (18k points)
ID: 33762 - Available when: Unlimited - Due to: Unlimited
| 8.5k views
3 like 0 dislike
20 answers
[Exercise] Coding (C) - asked Nov 16, 2017 in 2017-1 程式設計(一)AD by Shun-Po (18k points)
ID: 33758 - Available when: Unlimited - Due to: Unlimited
| 7.9k views
12,783 questions
183,442 answers
172,219 comments
4,824 users