2 like 0 dislike
2k views

(20%)請撰寫一個程式,幫字串做排序,請依照字典順序作為排序的依據,就是單字在英文字典中出現的順序。

輸入說明:

一開始會輸入一個正整數,代表接下來會有多少個單字要被輸入。輸入的單字不會超過100個,只會有小寫字母。

輸出說明:

請輸入排序後的所有單字,每一個字一行。

 

輸入範例:

6
imagine
imaginary
menagerie
manager
imagining
managing

 

輸出範例:

imaginary
imagine
imagining
manager
managing
menagerie

 

[Exam] asked in 2017-1 程式設計(一)AD by (30k points)
ID: 43451 - Available when: 2018-01-19 18:30 - Due to: 2018-01-19 21:30

edited by | 2k views

5 Answers

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


int main()
{
    int n,i,j;
** **** * * * * * * ******** *** * ** *
    {
        char str[n][30];
* * ** ***** * * ** * * ** ** ** *** ** * * * *****
*** *** * ** * ** * **** ***** *** ** * * * * **** ** ***** ** ** * * ** ** *
* * * ** * ***** ** *** *** **** ** * * ** ***** **** ** ******* *
        {
* * * * ** ** ****** * * * ****** * ** * * * ** ****** *** **** ** * * * * ** **
* ** ** * * * ** ** ** ** ***** * * ** * * ** ** ** ** * * * ***
**** ******* * * * ***** * ********** *** **** ** * * * ** *** * ** * ** * * ******** * * ** ** ** * *
** * **** *** * ** * * ** * ** * ********** ****** *** * * * ** * ***** * * * * * ** *
** * * * * **** ** ** * * * * * ** *** ** *** * * *** * *** ** ** * ***** ***** * ** ** * * * ** ** ****** temp[30];
*** ** * ** ** * * ** ** * * * * ** * ** * * * * ** * *** *** * * *** * ** * * * * * * * ** * ** ** *
*** * * ** * * * *** ** * ** * **** * * * * * * * * * * ** * ** ****** ****** * * * * ** * * * * * * * *** * **
* * * * * * * * * * * * **** * ***** * ** ***** * ****** * * ** ** * ** * ** * *** * ** ****** * * *** *
** ** * ** *** ** * ** * * * * * *** * * *** * * * * **** ** * * ******** *** ** * *
* * *** ** * * * ***** **** ** ** * ** * ** ** * ** * **
        }
* ** **** ***** * ** * * * *** * ** ** *** *** ** *** *
** * * * ** * * * * * * * * ** * * * * **** * ***** * ** ****** * *
    }
    return 0;
}
answered by (114 points)
0 0
Case 0: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main()
{
    int n,i,j,k,l,u;
    char ch[100][100],temp[100];
* * ****** *** ** * * * ***** ** * ***
    
    for(i=0;i<n;i++)
** ** * ** ** * * *** *** * ***
    
** ** * * * * ** ** *
    for(j=0;j<n-1;j++)
    {
* * ** ***** ** **** * ** ** ** ***
* *** *** * * * ****** ** ** ** ****
** *** * * **** *** * * ** ***** * ** ***** ** * * ** * ** * * * ** *
** * ***** * * * ** **** * * ***** ***** ** *
*** *** * * *** ** * * * * * * ** ***** ** ****** * ** **** * * * ******
*** * ****** ****** ** **** * * * **** *** **** * *** ******* * * ** *** **
**** ** * ** * * * * ******* ** *** ** * ** * ** ** *** ** ****** ** ** **
* * *********** ** * *** * * **** * * *** * ** * *** * * * *** ** ** * **
* ** * *** ****** *** * ** * ** ** * * ** * ** * ** * * * *** ****** ** ** * * *** *
** *** * *** ****** * *** ** * *** * ** ** ** * * ****** ** ***** **** ***
* *** **** * **** * ** * *** * ** * * * * * * ** * *** ** ** *** *** * ***
***** *** * * ** * * **** *** ***** * * ** ** * **** * * ** *** ** * **
*** *** ***** * * ** ** * * ** * * * ** * ** ** ***** * *** * ** *
*** * * ***** ** * * * ** **** * * * * * * ** * * ** * * * * *
** ** * * * * * * *** ** ** * * * ** *** *** * * ** ** *** * * * ** **** *
* **** *** * *** ** * ** * * *** ** ** * ** * * ** * * ** ** * **
* * * ** *** * ** ** ** ** * * ** * *** * ****
** * * * * * * ** * * ** * * ** **
    }
    
    for(i=0;i<n;i++)
** **** *** * *** * *** ****** * * *
*** ****** **** ******** ** * **** ****
}
answered by (192 points)
edited by
0 0
prog.c:1:1: error: expected '=', ',', ';', 'asm' or '__attribute__' at end of input
 test
 ^~~~
0 0
Case 0: Correct output
0 like 0 dislike
Hidden content!
* *** * * ** ****
int main()
{
** ** *** * s[i]=[500]
** * * * *** ** n,i;
* ** * ** ***** * *** * **** *** **
**** *** * *** * ** * * ****** ** *
* ** * *** * ** *
answered by (162 points)
0 0
prog.c: In function 'main':
prog.c:4:11: error: 'i' undeclared (first use in this function)
    char s[i]=[500]
           ^
prog.c:4:11: note: each undeclared identifier is reported only once for each function it appears in
prog.c:4:14: error: expected expression before '[' token
    char s[i]=[500]
              ^
prog.c:6:17: error: 'n' undeclared (first use in this function)
    scanf("%d\n",n);
                 ^
prog.c:7:4: error: expected declaration or statement at end of input
    scanf("%s\n",s);
    ^~~~~
0 like 0 dislike
Hidden content!
** ** * * **

int main()
{
**** * * * * * a,b,c,d;
*** ***** **
*** * * *** *** **** * * ** * **
* ** ** **** *
}
answered by (174 points)
0 0
prog.c: In function 'main':
prog.c:7:12: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'int' [-Wformat=]
    scanf("%s",a);
            ^
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main()
{
* * ** **** *** * * a;
    
* ** ** * **** * ***** *** ** * * * **** ** *
    
** *** * * *** * *** * * ** * *
* * ** ** *** * ** ** ** ** * * * *
* *** **** * ****** **** * ** * * *** * ***
****** ** *** ***** * * * * * * * * ** *
*** * * *** * ** * * ** *** ** ** **** * * ****
*** * ** ******** ** * ****** * * * *
* ** * *** ** * * ** ** ** 0;
}
answered by (215 points)
edited by
0 0
Case 0: Wrong output
0 0
Case 0: Wrong output
0 0
Case 0: Wrong output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.71.254.251
©2016-2025

Related questions

1 like 0 dislike
24 answers
[Exam] asked Jan 19, 2018 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 43456 - Available when: 2018-01-19 18:30 - Due to: 2018-01-19 21:30
| 4.2k views
1 like 0 dislike
24 answers
[Exam] asked Jan 19, 2018 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 43455 - Available when: 2018-01-19 18:30 - Due to: 2018-01-19 21:30
| 3.7k views
1 like 0 dislike
24 answers
[Exam] asked Jan 19, 2018 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 43454 - Available when: 2018-01-19 18:30 - Due to: 2018-01-19 21:30
| 5.3k views
2 like 0 dislike
24 answers
[Exam] asked Jan 19, 2018 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 43453 - Available when: 2018-01-19 18:30 - Due to: 2018-01-19 21:30
| 3.9k views
1 like 0 dislike
23 answers
[Exam] asked Jan 19, 2018 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 43452 - Available when: 2018-01-19 18:30 - Due to: 2018-01-19 21:30
| 3.6k views
12,783 questions
183,442 answers
172,219 comments
4,824 users