亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? link.c

?? 單向鏈表的升序建立
?? C
字號:
/*reserved at LIU Jing    Named :assignment_0
2007-9-13   used for create a link form min to max
re create it from max to min and to count it
to insert and delet    and display it in a new file */
#include <stdio.h>
#include <stdlib.h>

/* to define the structure of the link*/
typedef struct node
{
    int data;  //to store the numbers
    struct node *next;  //to point the next one
}
link;

/*fuction insert received an arguments , point head
to tell where is the link and x to tell which number want to
 insert into the link*/
int insert ( link *head ,int x)
{
    link *q, *p;

    p = head;
    q = ( link* ) malloc ( sizeof ( link ) );
    //q is used to store x and his link
    q->data = x;
    q->next = NULL;//make sure the link will not point to a place we don't know
    while (p->next != NULL && p->next->data <= x)
    {
        p = p->next;
        //if the number is less than the x move to next position
    }
    //to insert the x
    q->next = p->next;
    p->next = q;
    p = q->next;
    return 1;
}

//fuction insert_2 has the same fuction as insert but use for max to min
int insert_2 ( link *head, int x)
{
    link *q, *p;

    p = head;
    q = ( link* ) malloc ( sizeof ( link ) );
    //q is used to store x and his link
    q->data = x;
    q->next = NULL;//make sure the link will not point to a place we don't know
    while (p->next != NULL && p->next->data >= x)
    {
        p = p->next;
        //if the number is less than the x move to next position
    }
    //to insert the x
    q->next = p->next;
    p->next = q;
    p = q->next;
    return 1;
}

/* fuction delete_x is to delete the first x in the link
it received one argument head which tell us where the link]
is in the memory, if delete x successfully return 1 */
int delete_x ( link* head)
{
    link *p, *q;
    int x;

    scanf("%d",&x);//get in the x
    p = head;
    //if head->next == null ,the link must be an empty one
    while (p->next != NULL )
    {
        if ( p->next->data != x)
        {
            p = p->next;//move to the next position
        }
        else//if find the x and delete it
        {
            q = p->next;
            p->next = q->next;
            free ( q );
            return 0;
        }
    }
    printf(" no such a int in the link ");
    return 1;
}

/*fuction create has one argument head to tell the position of the link
it opens a file( user gives )and create a link form min to max,returns
head to tell other parts where the link is*/
link* create ( link *head )
{
    char filename [255];
    FILE *fp;
    int x = 0;

    head = ( link* ) malloc ( sizeof ( link ));
    head->next = NULL;

    printf("enter the filename you want to open:");
    scanf( "%s", filename );//get a file name

    fp = fopen ( filename ,"r" );//open only read
    while ( fp == NULL )
    {
        printf("ERROR!!!\nEnter the filename you want to open:");
        //can open it may be the file not exsist
        scanf( "%s", filename );
        fp = fopen ( filename ,"r" );
    }

    while ( (fscanf( fp, "%d", &x )) != EOF)//file not end
    {
        insert( head, x);
    }
    fclose ( fp );//close the file
    printf("link created sucessfully\n");
    return head;
}

//to tell how to use the programme
void help()
{
    printf("press c to create a new link\n"
           "    @ unless you use fuction a first \n"
           "    @ the link is from min to max."
           "press e to end the program\n"
           "press i to insert a int into the link\n"
           "    @ then you should give a int x\n "
           "press d to delete a int x"
           "    @ you should give a int then\n"
           "press r to turn link max to min\n"
           "press l to count the length of the link\n"
           "press a to empty the link in order to re_establish one\n"
           "press p to display the link in the file\n\n");
}


/*fuction errors received none and return none just to tell the user
the key can't open any fuctions of the program*/
void errors ()
{
    printf( "sorry, bad comments.\n ");
    help();
}

/* fuction delete_all received head
and to empty the old link and to create a
new link still in the position of the old */
void delete_all ( link *head )
{
    link *p, *q;
    p = head->next;
    //free every  crunode
    while ( p != NULL )
    {
        q = p;
        p = p->next;
        free ( q );
    }
    printf("now it is an empty link\n");
}

/*fuction search received head to locate the position of link
and is to find out the first x in the link ,return none*/
void search( link* head )
{
    int x;
    int count = 1,mark = 0;
    link *p;

    scanf("%d",&x);//what to find

    p = head->next;
    while ( p != NULL  )
    {
        if ( p->data != x )
        {
            //move to the next if it's not the x
            p = p->next;
            count++;
        }
        else
        {
            printf("now the %d is in the %d th place\n",x,count);
            mark = 1;
            break;
        }
    }
    if ( mark == 0 )
        printf("can't find such a(an) %d\n",x);
    else;//do nothing
}


/*fuction display received head and return none
it establish a new file( user gives the filename )
to display the link in order */
void display ( link *head )
{
    link *p;
    char display_filename[255];
    FILE *fp;

    //get the file name wanted establish
    printf ("enter the display_filename: ");
    scanf( "%s", display_filename);

    fp = fopen ( display_filename, "w");
    // open stytle write
    p = head->next;

    //write every data into the file in order
    while ( p != NULL)
    {
        fprintf ( fp,"%d ", p->data );
        p = p->next;
    }
    printf("displayed in %s\n",display_filename);
    fclose ( fp );
}

/*fuction re_create received head and return none
it used to create the link again from max to min */
void re_create ( link *head )
{
    link *p,*q,*r;

    if ( head->next == NULL )
    {
        printf(" empty link\n");
        //there is no need to create an empty link again
    }
    p = head->next;
    q = p->next;
    r = q->next;
    p->next = NULL;

    while ( q->next != NULL )
    {
        /*move the third crunode to the position before the
        second crunode,then the forth before the third */
        head->next = q;
        q->next = p;
        p = q;
        q = r;
        if ( r->next != NULL )
        {
            r = r->next;
        }
        else;//do nothing
    }
    head->next = q;
    q->next = p;
    printf("link re_create successfully\n");
}

/*fuction count received head and return none
to tell the user how many ints in the link */
void count ( link *head)
{
    int length = 0;
    link *p;

    p = head;
    while ( p->next != NULL )
    {
        p = p->next;
        length++;
    }
    printf ("the link now is %d",length);
}

//to give back all space to the system
void end ( link *head )
{
    delete_all( head );
    free( head );
}

int main()
{
    link* head;
    char option;
    int x = 0;
    int label = 0;

    //point head is to tell where is the link


    printf ("welcome ! press c to create a new link\n");
    printf ("press h for help\n");
    scanf( "%c", &option);

    /*to let the user choose which fuction he want to use
    how to use the program can be seen in fuction help*/
    while ( option != 'e')
    {
        switch ( option)
        {
        case 'a' :
            delete_all ( head );
        case 'c' :
            head = create ( head );
            break;
        case 'i':
        {
            scanf("%d",&x);
            if ( label % 2 == 0)
            insert ( head ,x);
            else insert_2 ( head ,x);
            break;
        }
        break;
        case 'd' :
            delete_x ( head );
            break;
        case 's':
            search( head );
            break;
        case 'r' :
        {
            re_create ( head );
            label++;
            break;
        }
        case 'p':
            display ( head );
            break;
        case 'h':
            help();
            break;
        case 'l':
            count( head );
            break;
        default :
            errors();
            break;
        }
        scanf( "%c", &option);
        scanf( "%c", &option);
        //option = getchar();
        //option = getchar();
    }
    end( head );
    return 0;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人午夜激情在线| 午夜精品在线视频一区| 成人动漫一区二区在线| 国产午夜精品一区二区三区四区| 国产成人亚洲综合a∨婷婷图片| 日本一区二区在线不卡| 91在线视频免费91| 依依成人精品视频| 4438成人网| 国产麻豆视频精品| 中文字幕一区二区三区视频 | 国产精品一区二区久久精品爱涩 | 国产欧美精品在线观看| 成人综合在线视频| 亚洲一区二区三区影院| 精品欧美久久久| 成人免费高清视频| 日韩和欧美一区二区三区| 精品国产伦一区二区三区免费| 国产91丝袜在线18| 亚洲福利一二三区| 久久久久久久久久久久电影| 一本大道久久精品懂色aⅴ| 视频一区在线视频| 国产欧美日韩在线观看| 欧美午夜不卡在线观看免费| 国产美女一区二区| 亚洲国产精品久久人人爱蜜臀| 久久综合色之久久综合| 欧美日韩一级黄| 久久亚洲欧美国产精品乐播| 久久久www免费人成精品| 波多野结衣中文字幕一区二区三区| 亚洲五月六月丁香激情| 精品电影一区二区三区| 欧美曰成人黄网| 国产在线精品一区二区不卡了 | 亚洲欧洲性图库| 日韩一区二区三区视频在线观看| 成人看片黄a免费看在线| 日韩国产精品91| 亚洲欧洲av一区二区三区久久| 国产精品久久久久久久久免费樱桃| 欧美午夜电影网| 99久久99久久精品国产片果冻| 免费在线看成人av| 亚洲一二三区在线观看| 亚洲欧洲一区二区在线播放| 99久久精品久久久久久清纯| 日韩精品一区二区在线| 在线免费观看日本欧美| 国产精品一线二线三线| 五月综合激情网| 亚洲乱码日产精品bd| 国产亚洲欧美激情| 精品久久一二三区| 91精品国产色综合久久不卡电影| 欧美综合天天夜夜久久| 99这里只有久久精品视频| 国产精品一卡二卡| 男女视频一区二区| 日韩不卡在线观看日韩不卡视频| 亚洲女厕所小便bbb| 成人欧美一区二区三区黑人麻豆| 欧美精品一区二区三| 欧美成人精精品一区二区频| 91精品国产aⅴ一区二区| 在线免费观看日本一区| 97久久人人超碰| av一本久道久久综合久久鬼色| 国产成人av一区二区三区在线| 美女在线观看视频一区二区| 日本精品裸体写真集在线观看| 国产精品综合网| 午夜影院在线观看欧美| 亚洲激情校园春色| 亚洲婷婷在线视频| 亚洲另类色综合网站| 亚洲欧洲美洲综合色网| 国产精品女人毛片| 成人免费一区二区三区在线观看 | 蜜桃视频第一区免费观看| 亚洲小少妇裸体bbw| 午夜电影一区二区三区| 蜜桃视频一区二区| 免费观看在线综合色| 日本亚洲天堂网| 老司机午夜精品99久久| 国产在线观看一区二区| 国产99久久久久| 91一区二区三区在线观看| 91高清视频免费看| 欧美日韩高清一区二区不卡| 717成人午夜免费福利电影| 7777精品伊人久久久大香线蕉的 | 欧美日韩卡一卡二| 欧美一级在线观看| 日韩欧美的一区二区| 久久久av毛片精品| 中文字幕日韩精品一区| 亚洲毛片av在线| 日本亚洲三级在线| 免费成人av在线播放| 国产一区二区福利视频| av中文字幕不卡| 欧美日韩在线三级| 久久综合狠狠综合| 中文字幕一区二区三区在线观看 | 日日夜夜精品免费视频| 狠狠色综合色综合网络| 99久久久精品免费观看国产蜜| 欧美三级在线播放| 久久奇米777| 亚洲日本成人在线观看| 日本欧美一区二区| 粉嫩高潮美女一区二区三区 | 99久久综合狠狠综合久久| 欧美自拍丝袜亚洲| 久久伊人中文字幕| 一区二区三区欧美在线观看| 免费在线一区观看| 91老司机福利 在线| 精品美女在线播放| 亚洲图片有声小说| 粉嫩一区二区三区在线看| 欧美日韩视频在线第一区| 久久久久久免费网| 亚洲精选一二三| 国产成人精品三级麻豆| 69成人精品免费视频| 日韩一区中文字幕| 国产高清久久久久| 欧美一区二区视频在线观看2020| 亚洲欧美日韩久久| 高清shemale亚洲人妖| 91精品国产一区二区三区香蕉| 老司机精品视频导航| 精品无人区卡一卡二卡三乱码免费卡 | 精品伦理精品一区| 亚洲国产精品久久人人爱| 欧美一区二区播放| 一区二区三区在线观看视频| 国产宾馆实践打屁股91| 欧美一区日本一区韩国一区| 一二三四区精品视频| av网站免费线看精品| 国产日韩欧美在线一区| 九九精品一区二区| 91精品国产入口在线| 亚洲一级二级三级| 一本大道久久精品懂色aⅴ| 中文字幕不卡一区| 成人美女视频在线看| 国产欧美综合在线| 国产一区999| 久久久美女艺术照精彩视频福利播放| 免费人成精品欧美精品| 欧美高清hd18日本| 琪琪一区二区三区| 欧美一级黄色片| 麻豆91精品91久久久的内涵| 欧美一区二区精品久久911| 午夜精品久久久久久久99水蜜桃 | 韩国精品久久久| 欧美α欧美αv大片| 蜜臀va亚洲va欧美va天堂| 欧美乱妇15p| 日韩激情一二三区| 欧美一区二区网站| 日韩欧美电影一二三| 日韩精品在线一区| 免费在线观看日韩欧美| 91精品国产麻豆| 美女精品自拍一二三四| 日韩视频123| 极品尤物av久久免费看| 久久精品夜色噜噜亚洲a∨| 国内成人自拍视频| 国产视频一区在线播放| 成人精品免费看| 一级做a爱片久久| 91精品国产色综合久久不卡电影| 精品一区二区在线看| 国产三级精品视频| 91在线码无精品| 亚洲国产成人av网| 欧美电影精品一区二区| 国产精品99久久久久久有的能看| 亚洲va欧美va人人爽| 3d动漫精品啪啪一区二区竹菊| 日本中文一区二区三区| 国产三级精品三级| 在线免费观看日本一区| 久久66热re国产| 亚洲欧洲www| 5566中文字幕一区二区电影| 国产精品538一区二区在线| 国产精品黄色在线观看| 91精品综合久久久久久| 国产91精品入口|