8 like 0 dislike
196 views
請寫一個程式,找出一個句子當中出現頻率最高的單子。

 

輸入說明:

會輸入一個英文句子,以”.”作為結束。

 

輸出說明:

輸出句子當中出現最多次的單字,請將所有字母轉成小寫,如果沒有一個單字是最多的,就在螢幕上輸出none。

 

輸入範例1:

This is a pen.

 

輸出範例1:

none

 

輸入範例2:

Pen pineapple apple pen.

 

輸出範例2:

pen
[Exam] asked in 2017-1 程式設計(一)AD by (18k points)
ID: 36175 - Available when: 2017-12-08 18:30 - Due to: 2017-12-08 21:00
| 196 views

3 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
* *** * ** * * ** *** * ch1();
* * ** *** *** * ** * *** ** **** *
    {
* ** *** ********** *** * ** **** ** * **** * ** ** ****** *
** * *** ** ** ***** * *** * ** ** ** ***** ** * ** *** ***
***** * * * * * ** **** * * * **** ** ****
* ** ** ** *** * * ***** * * ***** * * *
* * * * ** * ** * *** *** * **** *** *** ** **** *
** * ** ** ** ** * ** ** * * * * * *
* * * * **** * *** *** * ** * *** *** * ** ***** * ** ** ** *** * * * *** ** * **********
* ** ** * *** *** *** *** * *** * *
*** * ** * *** * *** * *** ** ** * ** ** ** *** ** * * * * ***    
* ** * *** **** ** * * ***** * * * *
* * * ***** * ** * ** * 0 ;
    
    
    }
answered by (194 points)
edited by
0 0
prog.c:2:24: error: expected ';', ',' or ')' before 'str'
 int count(const char[] str, const char key[]);
                        ^~~
prog.c: In function 'main':
prog.c:8: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:9:11: error: stray '\342' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
           ^
prog.c:9:12: error: stray '\200' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
            ^
prog.c:9:13: error: stray '\234' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
             ^
prog.c:9:14: error: stray '\345' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
              ^
prog.c:9:15: error: stray '\205' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
               ^
prog.c:9:16: error: stray '\261' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                ^
prog.c:9:17: error: stray '\344' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                 ^
prog.c:9:18: error: stray '\275' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                  ^
prog.c:9:19: error: stray '\277' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                   ^
prog.c:9:20: error: stray '\347' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                    ^
prog.c:9:21: error: stray '\224' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                     ^
prog.c:9:22: error: stray '\250' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                      ^
prog.c:9:23: error: stray '\344' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                       ^
prog.c:9:24: error: stray '\272' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                        ^
prog.c:9:25: error: stray '\206' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                         ^
prog.c:9:27: error: expected expression before '%' token
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                           ^
prog.c:9:30: error: stray '\347' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                              ^
prog.c:9:31: error: stray '\250' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                               ^
prog.c:9:32: error: stray '\256' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                                ^
prog.c:9:33: error: stray '\350' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                                 ^
prog.c:9:34: error: stray '\213' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                                  ^
prog.c:9:35: error: stray '\261' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                                   ^
prog.c:9:36: error: stray '\346' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                                    ^
prog.c:9:37: error: stray '\226' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                                     ^
prog.c:9:38: error: stray '\207' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                                      ^
prog.c:9:39: error: stray '\345' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                                       ^
prog.c:9:40: error: stray '\255' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                                        ^
prog.c:9:41: error: stray '\227' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                                         ^
prog.c:9:42: error: stray '\346' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                                          ^
prog.c:9:43: error: stray '\257' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                                           ^
prog.c:9:44: error: stray '\215' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                                            ^
prog.c:9:45: error: stray '\342' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                                             ^
prog.c:9:46: error: stray '\200' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                                              ^
prog.c:9:47: error: stray '\235' in program
    printf(\xe2\x80\x9c\xe5\x85\xb1\xe4\xbd\xbf\xe7\x94\xa8\xe4\xba\x86 %d \xe7\xa8\xae\xe8\x8b\xb1\xe6\x96\x87\xe5\xad\x97\xe6\xaf\x8d\xe2\x80\x9d, count(str, key));
                                               ^
prog.c: At top level:
prog.c:13:24: error: expected ';', ',' or ')' before 'str'
 int count(const char[] str)
                        ^~~
0 0
prog.c: In function 'main':
prog.c:6:15: warning: missing terminating " character
     for(;ch1!=";)
               ^
prog.c:6:15: error: missing terminating " character
     for(;ch1!=";)
               ^~~
prog.c:7:5: error: expected expression before '{' token
     {
     ^
prog.c:21:5: error: expected declaration or statement at end of input
     }
     ^
0 like 0 dislike
Hidden content!
** ******* *
int main ()
{
* ****** * *** * * ***
* ** * *** * ***** ** * * * * * * * * * * ***
****** *** ** *
**** * * * * * ** * 0;
}
answered by (215 points)
edited by
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main(void)
{
** **** * ** ** ** ******* * ***** * * ***** *** last=0,cnt=0,num;
       while(1)
     {
****** **** * ** *** * ** ** * ** **** ** * * ** *** * input number");
* * * * * * **** * * ***** * * * ** * ** *** ** * *
* ** * ** ** * ******* *** * * * ** * ** * * *** * *
* * * *** * * ** ***** *** * *** * *** * ** ******
* * * * * * * ******* **** * ** ** * * *** * *** ** ** * **** ***** * * * * * * *** **
*** * * ** ** * ** ** ****** ** **** * * ****
   }
* ** * *** * ** * ** * * * * * ** * *** ** *** * ******* ***** * ** * * ** * *** *** * * *** ** ** * *
** * * * * ** ** * * * * * ** * *** * ** ** ** * * **** * * * ****** **** ** ** * * * ** * **
* ** ****** * ** ** * **** *** * ** * * * * 0;
}
answered by (190 points)
0 0
prog.c: In function 'main':
prog.c:13:4: error: expected expression before '}' token
    }
    ^
prog.c:14:26: warning: format '%d' expects argument of type 'int', but argument 2 has type 'int *' [-Wformat=]
                 printf("%d\n",&num);
                          ^
prog.c:15:17: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
                 system("pause");
                 ^~~~~~
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.71.254.30
©2016-2024

Related questions

2 like 0 dislike
8 answers
[Normal] Coding (C) - asked Dec 20, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 38155 - Available when: Unlimited - Due to: Unlimited
| 563 views
2 like 0 dislike
5 answers
[Normal] Essay (Open question) - asked Dec 20, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 38147 - Available when: Unlimited - Due to: Unlimited
| 251 views
12,783 questions
183,443 answers
172,219 comments
4,824 users