| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 907 人关注过本帖
标题:排序怎么做大家给看看,谢谢
只看楼主 加入收藏
刘丹丹123
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2010-12-2
结帖率:0
收藏
已结贴  问题点数:0 回复次数:10 
排序怎么做大家给看看,谢谢
#include"Windows.h"
#include <stdio.h>
#include <conio.h>
#include <fstream.h>
#include <iostream.h>
#include   <time.h>  
#define TRUE                1
#define FALSE          0

char * STextLine[1000];
char * DTextLine[1000];

int  CurrentLine= 0;
int PageFirstLine= 0;
int LastLine = 0 ;

unsigned long dtime = 0;
unsigned long startTime=0;


void welcome1();
void welcome2();
int  menu1();//功能表
void ReadSourceText(char * sfile);
void ReadSourceText1(char * sfile);
void ReadSourceText2(char * sfile);
void Display(int);
void GetInput();
void Compare();
void Test();
void TestText1();
void TestText2();
void TestText3();
void TestText4();
void TestText5();
void TestText6();
void TestText7();
void TestText8();
void TestText9();
void TestText10();
void TestText11();
void TestText12();
void TestText13();
void TestText14();
void TestText15();
void TestText16();
void TestText17();
void TestText18();
void TestText19();
void TestText20();
void Rank();
void ManageText(int);
void Manage();

//---------------------menu和welcome块-----------------------------------------------------
int menu1()                                                         //menu函数
{
    int response;
    cprintf("****************************************:\n");
    cprintf("\n");
   
    cprintf("1.测验区:\n");
    cprintf("2.成绩排行:\n");
    cprintf("3.试卷管理:\n");
    cprintf("0.退出:\n");
    cprintf("\n");
    cprintf("请输入您的选择:\n");
    scanf("%d",&response);
    return (response);
}

int menu2()
{
    int response;
    cprintf("****************************************:\n");
    cprintf("\n");
    cprintf("1.文章一:\n");
    cprintf("2.文章二:\n");
    cprintf("3.文章三:\n");
    cprintf("4.文章四:\n");
    cprintf("5.文章五:\n");
    cprintf("6.文章六:\n");
    cprintf("7.文章七:\n");
    cprintf("8.文章八:\n");
    cprintf("9.文章九:\n");
    cprintf("10.文章十:\n");
    cprintf("11.文章十一:\n");
    cprintf("12.文章十二:\n");
    cprintf("13.文章十三:\n");
    cprintf("14.文章十四:\n");
    cprintf("15.文章十五:\n");
    cprintf("16.文章十六:\n");
    cprintf("17.文章十七:\n");
    cprintf("18.文章十八:\n");
    cprintf("19.文章十九:\n");
    cprintf("20.文章二十:\n");
    cprintf("0.返回上一级:\n");
    cprintf("\n");
    cprintf("请输入您的选择:\n");
    scanf("%d",&response);
    return (response);
}

void welcome1()                                                     //welcome1函数
{
    cprintf("****************************************:\n");
    cprintf("\n");
    cprintf("             欢迎进入打字测试系统:\n");
    cprintf("\n");
    cprintf("               辅导老师:张银霞\n");
    cprintf("               设计人员:谢菊林\n");
    cprintf("                     刘丹丹\n");
    cprintf("             阴启刚\n");
    cprintf("               设计时间:2010年11月20日\n");
    cprintf("\n");
    cprintf("****************************************:\n");
}

void welcome2()                                                     //welcome2函数
{
    cprintf("****************************************:\n");
    cprintf("\n");
    cprintf("             <测试区>:\n");
    cprintf("\n");
    cprintf("****************************************:\n");
}
//-----------------------------------------------------------------------------------------



//-----------------------compare块------------------------------------------------------------------
void ReadSourceText1(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"r")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        STextLine[LastLine] =(char*)malloc(81) ;
        fgets(STextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}

void ReadSourceText2(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}
void ReadSourceText3(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}void ReadSourceText4(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}void ReadSourceText5(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}void ReadSourceText6(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}void ReadSourceText7(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}void ReadSourceText8(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}void ReadSourceText9(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}void ReadSourceText10(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}void ReadSourceText11(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}void ReadSourceText12(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}void ReadSourceText13(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}void ReadSourceText14(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}void ReadSourceText15(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}void ReadSourceText16(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}
void ReadSourceText17(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}void ReadSourceText18(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}void ReadSourceText19(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        LastLine ++ ;
    }
    fclose(fp);
}void ReadSourceText20(char * sfile)
{
    FILE * fp ;
    CurrentLine = 0;
    PageFirstLine= 0;
    LastLine = 0 ;
    if((fp = fopen(sfile,"rt")) == NULL)
    {
        printf("找不到文件:%s",sfile);
        exit(0);
    }
    while (!feof(fp))
    {
        DTextLine[LastLine] =(char*)malloc(81) ;
        fgets(DTextLine[LastLine],81,fp) ;
        
        LastLine ++ ;
    }
    fclose(fp);
}
void Compare()
{
    unsigned int TotalChar = 0 ;
    unsigned int CorrectChar = 0 ;
    int i,j, l ;
    for(i = 0 ; i < LastLine ;i ++)
    {
        l = strlen(DTextLine[i]);
        if(l > 0)
        {
            for(j = 0 ; j < l ; j ++)
            {
                if(STextLine[i][j]==' ')    continue ;
                if(DTextLine[i][j]==STextLine[i][j])
                {
                    j ++ ;
                    if(DTextLine[i][j]==STextLine[i][j])
                    {    CorrectChar ++ ;
                    TotalChar ++ ;}
                }else
                {
                    j ++ ;
                    TotalChar ++ ;
                }
            }
        }
    }
    cprintf("总共输入:%u个字",TotalChar-1);     //因为同时还输入了结束符'#',所以要减去1
    cprintf("\n");
    cprintf("正确输入:%u个字",CorrectChar);   //同上
    cprintf("\n");
    cprintf("所花时间:%u秒",dtime);
    cprintf("\n");
    cprintf("打字速度为:%u字/分钟",(TotalChar-1)*60/dtime);
    cprintf("\n");
    cprintf("准确率为:%u%%",CorrectChar*100/(TotalChar-1));
    cprintf("\n");
}
//----------------------------------------------------------------------------------------------


//-----------------------test块----------------------------------------------------------------
void Test()
{
    int response;
    welcome2();
    //cprintf("******************************:\n");
    cprintf("   <打字测试排行榜榜首信息(暂无内容)>:\n");
    //char RankText[] = "RankText.TXT";
    //ReadSourceText(RankText);
    //cprintf("\n");
    response=menu2();
    while(response!=0)
    {
        switch(response)
        {case 1:
         TestText1();
         break;
         case 2:
         TestText2();
         break;
         case 3:
         TestText3();
         break;
         case 4:
         TestText4();
         break;
         case 5:
         TestText5();
         break;
         case 6:
         TestText6();
         break;
         case 7:
         TestText7();
         break;
         case 8:
         TestText8();
         break;
         case 9:
         TestText9();
         break;
         case 10:
         TestText10();
         break;
         case 11:
         TestText11();
         break;
         case 12:
         TestText12();
         break;
         case 13:
         TestText13();
         break;
         case 14:
         TestText14();
         break;
         case 15:
         TestText15();
         case 16:
         TestText16();
         break;
         case 17:
         TestText17();
         break;
         case 18:
         TestText1();
         break;
         case 19:
         TestText19();
         break;
         case 20:
         TestText20();
         break;
         
         default:cprintf("请输入0,1,2,3中的一个数:\n");
        }
        response=menu2();                 /* ------------ 再次显示一到三十篇文章的界面 ------------ /*
    }
}

void ReadSourceText(char * sfile)
{
    FILE *fp;
    char ch;
    if((fp=fopen(sfile,"rt"))==NULL)
    {
        printf("找不到该文件:\n");
        //getch();
        exit(0);
    }
    ch=fgetc(fp);                        /* ------------从内部文件中读出文章-----------*/
    while(ch!=EOF)                  /* --------------当没有遇到结束符时则继续 -----------*/
    {
        putchar(ch);                /* --------------将文章逐字的输到屏上---------*/
        ch=fgetc(fp);
    }
    fclose(fp);
}

void Display(int ch)
{
    char SampleFile[20] = "SAMPLE1.TXT";
    sprintf(SampleFile,"SAMPLE%1d.TXT",ch);
    printf("您选取的文章是:%s\n",SampleFile);
    cprintf("   以下为测试内容:\n");
    ReadSourceText(SampleFile);
    printf("\n");
}

void GetInput()                           //为了方便比较及良好的文件管理,将用户输入的内容临时保存在temp.txt文件里面
{   
    char ch;

    ofstream outstuf;
    outstuf.open("temp.txt",ios::out);
    if(!outstuf)
    {
        cerr<<"File could not be oper."<<endl;
        abort();
    }
    cprintf("******************************:\n");
    cprintf("    请开始输入,以#号结束\n");
    cprintf("******************************:\n");
    startTime=GetTickCount();                              //开始计时
    while(ch!='#')
    {
        cin>>ch;
        outstuf<<ch;   
    }
   
    dtime=(GetTickCount()-startTime)/1000;                //截止计时,计算时差
    outstuf.close();
}

void TestText1()
{
    Display(1);
    GetInput();
    ReadSourceText1("SAMPLE1.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}

void TestText2()
{
    Display(2);
    GetInput();
    ReadSourceText1("SAMPLE2.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}

void TestText3()
{
    Display(3);
    GetInput();
    ReadSourceText1("SAMPLE3.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}

void TestText4()
{
    Display(4);
    GetInput();
    ReadSourceText1("SAMPLE4.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}

void TestText5()
{
    Display(5);
    GetInput();
    ReadSourceText1("SAMPLE5.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText6()
{
    Display(6);
    GetInput();
    ReadSourceText1("SAMPLE6.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText7()
{
    Display(7);
    GetInput();
    ReadSourceText1("SAMPLE7.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText8()
{
    Display(8);
    GetInput();
    ReadSourceText1("SAMPLE8.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText9()
{
    Display(9);
    GetInput();
    ReadSourceText1("SAMPLE9.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText10()
{
    Display(10);
    GetInput();
    ReadSourceText1("SAMPLE10.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText11()
{
    Display(11);
    GetInput();
    ReadSourceText1("SAMPLE11.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText12()
{
    Display(12);
    GetInput();
    ReadSourceText1("SAMPLE12.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText13()
{
    Display(13);
    GetInput();
    ReadSourceText1("SAMPLE13.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText14()
{
    Display(14);
    GetInput();
    ReadSourceText1("SAMPLE14.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText15()
{
    Display(15);
    GetInput();
    ReadSourceText1("SAMPLE15.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText16()
{
    Display(16);
    GetInput();
    ReadSourceText1("SAMPLE16.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText17()
{
    Display(17);
    GetInput();
    ReadSourceText1("SAMPLE17.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText18()
{
    Display(18);
    GetInput();
    ReadSourceText1("SAMPLE18.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText19()
{
    Display(19);
    GetInput();
    ReadSourceText1("SAMPLE19.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText20()
{
    Display(20);
    GetInput();
    ReadSourceText1("SAMPLE20.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}








{
    Display(21);
    GetInput();
    ReadSourceText1("SAMPLE21.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText22()
{
    Display(22);
    GetInput();
    ReadSourceText1("SAMPLE22.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText23()
{
    Display(23);
    GetInput();
    ReadSourceText1("SAMPLE23.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText24()
{
    Display(24);
    GetInput();
    ReadSourceText1("SAMPLE24.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText25()
{
    Display(25);
    GetInput();
    ReadSourceText1("SAMPLE25.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText26()
{
    Display(26);
    GetInput();
    ReadSourceText1("SAMPLE26.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText27()
{
    Display(27);
    GetInput();
    ReadSourceText1("SAMPLE27.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText28()
{
    Display(28);
    GetInput();
    ReadSourceText1("SAMPLE28.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText29()
{
    Display(29);
    GetInput();
    ReadSourceText1("SAMPLE29.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
void TestText30()
{
    Display(30);
    GetInput();
    ReadSourceText1("SAMPLE30.txt");
    ReadSourceText2("temp.txt");
    Compare();
    cprintf("\n");
}
//--------------------------------------------------------------------------------------------------





//-------------------rank块-----------------------------------------------------
void Rank()
{
    cprintf("           欢迎进入排行榜(暂无内容):\n");
}
//------------------------------------------------------------------------------


//------------------manage块----------------------------------------------------
void ManageText(int k)
{
    char SampleFile[20] = "SAMPLE1.TXT";
    sprintf(SampleFile,"SAMPLE%1d.TXT",k);
    printf("您选取的文章是:%s\n",SampleFile);
    printf("开始输入(以#号结束):\n");
    char ch;
    ofstream outstuf;
    outstuf.open(SampleFile,ios::out);
    if(!outstuf)
    {
        cerr<<"File could not be oper."<<endl;
        abort();
    }
    while(ch!='#')
    {
        cin>>ch;
        outstuf<<ch;   
    }
    outstuf.close();
    printf("\n");
}


void Manage()
{
    cprintf("欢迎进入管理区(修改测试文件内容)\n");
    int response;
    response=menu2();
    while(response!=0)
    {
        switch(response)
        {case 1:
         ManageText(1);
         break;
         case 2:
         ManageText(2);
         break;
         case 3:
         ManageText(3);
         break;
         case 4:
         ManageText(4);
         break;
         case 5:
         ManageText(5);
         break;
         case 6:
         ManageText(6);
         break;
         case 7:
         ManageText(7);
         break;
         case 8:
         ManageText(8);
         break;
         case 9:
         ManageText(9);
         break;
         case 10:
         ManageText(10);
         break;
         case 11:
         ManageText(11);
         break;
         case 12:
         ManageText(12);
         break;
         case 13:
         ManageText(13);
         break;
         case 14:
         ManageText(14);
         break;
         case 15:
         ManageText(15);
         break;
         case 16:
         ManageText(6);
         break;
         case 17:
         ManageText(17);
         break;
         case 18:
         ManageText(18);
         break;
         case 19:
         ManageText(19);
         break;
         case 20:
         ManageText(20);
         break;
         case 21:
         ManageText(21);
         break;
         case 22:
         ManageText(22);
         break;
         case 23:
         ManageText(23);
         break;
         case 24:
         ManageText(24);
         break;
         case 25:
         ManageText(25);
         break;
         case 26:
         ManageText(26);
         break;
         case 27:
         ManageText(27);
         break;
         case 28:
         ManageText(28);
         break;
         case 29:
         ManageText(29);
         break;
         case 30:
         ManageText(30);
         break;
         default:cprintf("请输入一个数:\n");
        }
        response=menu2();
    }
}
//-------------------------------------------------------------------------------
void wu()
{ int   n;
srand(time(NULL));
n=1+rand()%30;
switch(n)
{      case 1:
         TestText1();
         break;
         case 2:
         TestText2();
         break;
         case 3:
         TestText3();
         break;
         case 4:
         TestText4();
         break;
         case 5:
         TestText5();
         break;
         case 6:
         TestText6();
         break;
         case 7:
         TestText7();
         break;
         case 8:
         TestText8();
         break;
         case 9:
         TestText9();
         break;
         case 10:
         TestText10();
         break;
         case 11:
         TestText11();
         break;
         case 12:
         TestText12();
         break;
         case 13:
         TestText13();
         break;
         case 14:
         TestText14();
         break;
         case 15:
         TestText15();
         case 16:
         TestText16();
         break;
         case 17:
         TestText17();
         break;
         case 18:
         TestText1();
         break;
         case 19:
         TestText19();
         break;
         case 20:
         TestText20();
         break;
        
         default:;
}

}
void rui()
{int a;
cout<<"请选择你的考察方式: (1)随机文章,(2)指定文章:"<<endl;

cin>>a;
switch(a)
{ case 1:
 wu();
case 2:
    Test();
}
}

//-------------------------main块------------------------------------------------
void main()                     //主函数
{
    int response;
    welcome1();
    response=menu1();
    while(response!=0)
    {
        switch(response)
        {case 1:
         rui();
         break;
         case 2:
         Rank();
         break;
         case 3:
         Manage();
         break;
         default:cprintf("请输入0,1,2,3中的一个数:\n");
        }
        response=menu1();
    }
}
搜索更多相关主题的帖子: void long include 功能表 
2010-12-02 15:21
qq8801103
Rank: 5Rank: 5
来 自:苏州中科大软件学院
等 级:职业侠客
威 望:1
帖 子:422
专家分:340
注 册:2009-10-8
收藏
得分:7 
楼主你的问题不清楚

Discuz!  
好好学习  天天向上
2010-12-02 15:24
刘丹丹123
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2010-12-2
收藏
得分:0 
就是想把测试的几个人按照打字速度给出排序,得再加一个名字的录入功能
2010-12-02 16:46
刘丹丹123
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2010-12-2
收藏
得分:0 
谢谢大家了
2010-12-02 16:47
刘丹丹123
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2010-12-2
收藏
得分:0 
本来是30篇文章,有些地方改错了
2010-12-02 16:49
zhoufeng1988
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:北京
等 级:贵宾
威 望:27
帖 子:1432
专家分:6329
注 册:2009-5-31
收藏
得分:7 
看看先~
2010-12-03 17:41
laoyang103
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:内蒙古包头
等 级:贵宾
威 望:19
帖 子:3082
专家分:11056
注 册:2010-5-22
收藏
得分:7 
楼主的排序属于结构体数组的排序吧
选择法就可以
程序代码:
#include <iostream.h>
void sort(int a[],int n)
{
    int temp,k;
    for(int i=0;i<n-1;i++)
    {
        k=i;
        for(int j=i+1;j<n;j++)
        {
            if(a[j]>a[k])
                k=j;
            if(i=!k)
            {
                temp=a[i];
                a[i]=a[k];
                a[k]=temp;
            }
        }
    }
}
int main()
{
    int a[10]={7,9,8,2,1,4,3,5,6,14};
    sort(a,10);
    for(int i=0;i<10;i++)
        cout<<a[i]<<"  ";
    return 0;
}


                                         
===========深入<----------------->浅出============
2010-12-03 18:28
刘丹丹123
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2010-12-2
收藏
得分:0 
不对啊
2010-12-04 19:26
laoyang103
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:内蒙古包头
等 级:贵宾
威 望:19
帖 子:3082
专家分:11056
注 册:2010-5-22
收藏
得分:0 
程序代码:
#include <iostream.h>
void sort(int a[],int n)
{
    int temp,k;
    for(int i=0;i<n-1;i++)
    {
        k=i;
        for(int j=i+1;j<n;j++)
        {
            if(a[j]>a[k])
                k=j;
        }
        if(i!=k)
        {
            temp=a[i];
            a[i]=a[k];
            a[k]=temp;
        }
    }
}
int main()
{
    int a[10]={7,9,8,2,1,4,3,5,6,14};
    sort(a,10);
    for(int i=0;i<10;i++)
        cout<<a[i]<<"  ";
    return 0;
}

楼主实在不好意思   这里写错了  对不起  恳请楼主宽恕

                                         
===========深入<----------------->浅出============
2010-12-10 10:46
刘丹丹123
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2010-12-2
收藏
得分:0 
怎么有错误啊
2010-12-11 10:19
快速回复:排序怎么做大家给看看,谢谢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.043084 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved