排序问题 C语言

来源:百度知道 编辑:UC知道 时间:2024/05/20 10:40:32
Project 2: Sort Poems
Time Limit: 1 second
主要目的就是给诗排序然后输出 具体的看sample可以看懂,再不行就看下面的讲解~
Input Specification:
For each test case, the first line contains two positive integers Sn(≤1000) and Ln(≤100), which are the total numbers of segments and lines per segment, respectively. Then Sn×Ln lines follow, which arethe contents of Sn segments. Each line contains no more than 80 characters. It is guaranteed that the content of each overlapped line is unique.The input ends with Sn and Ln both being 0. That case must NOT be processed.
Output Specification:
For each test case, output to the standard output. First print a line saying"Scenario #k", where k is the number of the test case (starting from 1). Then, foreach case, print the complete poem out. There must be one blank line between theoutputs of two neighboring cases, but no extra blank line at the end of output.

Sample Input:

2 4
Return all courtesies that he affords; \

#include<stdio.h>
#include<stdlib.h>

typedef struct SortPoems *PtrToNode; /**********定义一个结构指针************/
typedef PtrToNode Poems;

struct SortPoems /**************结构指针的内部****************/
{
char line[100][80];
int m,n;
Poems next;
};

int CompareNext(Poems A,Poems B,int n); /***********定义一个比较最后一行和第一行的函数***************/
int ComparePre(Poems A,Poems B,int n); /***********定义一个比较第一行和最后一行的函数*************/

int main(void)
{

char c;
int i,j,k,h,l,u;
Poems Pe[10],Qe,Re; //
Poems head[10], tail[10], Tmp;

int o=0;
Pe[o] = (struct SortPoems *)malloc(sizeof(struct SortPoems));
head[o] = Pe[o];//
tail[o] = Pe[o];//
scanf("%d%d",&h,&l);
Pe[o]->m=h;//
Pe[o]->n=l;//
getchar();

if(h==0&&l==0) return 0;