SlideShare una empresa de Scribd logo
1 de 238
Descargar para leer sin conexión
elease
R
 寫程式?那些老師沒教的事
    Code Smart, Don’t Code Hard

        2012/07/15	 @StudyArea-Taichung
      畢玉泉	 (小畢/CrBoy)	 	 <crboy@crboy.net>
在開始之前...

別怕!多問問題!

今天只做粗淺簡介,但很歡迎深入討論!

如果出現冷笑話...要笑!

自由進出上廁所講手機或睡覺

多問問題! 別怕!

萬一講太久可以發問「請問幾點下課?」XD
我是誰?
經歷

2007 年成大資工系程式設計競賽-優等
2007 年全國大專電腦軟體設計競賽甲組-佳作
2007 年 ACM ICPC 亞洲區台灣賽區-第 13 名
2008 年第三屆南區大專院校程式設計競賽-進階組第一名
2008 年成大資工系程式設計競賽進階組-第一名
協辦 Ubuntu-TW 社群全台相關活動 2007 - 迄今
2008 年間,於系內自行主講數場 C 語言基礎觀念教學課程
2008 年全國大專電腦軟體設計競賽甲組-第三名
主講「U很大,U不用錢 - Ubuntu Linux 介紹」於國立成功大學 (http://goo.gl/lEnCN) 2009/03/24
主講「MozTW & Ubuntu 自由新生代」於高雄應用科技大學 (http://goo.gl/CgtBK) 2009/07/13
主講「Ubuntu Linux 簡介」於台南四校資訊社團聯合迎新 2009/10/31
「自由軟體應用與教學」於雲林縣口湖國小 2010/01/21
2010 年台灣駭客年會 場務組工作人員
Ubuntu-TW 社群文件組(Doc Team)負責人 2010/10 - 迄今
2011 年台灣駭客年會 場務組工作人員
2011 年開源人年會 場務組工作人員
2011 年資安技能金盾獎-第三名
主講「那些老師沒教的事 - Code Smart, Don’t Code hard」於國立成功大學 2012/03/29
現在是打雜的
那...你是誰?
你為什麼在這?
今天我們以	 C	 語言為主
有空的話再來點	 PHP
我們以前都怎麼寫程式的?
??
那.....Debug呢?
測試訊息印太多?
程式還是怪怪的....?
你真的很努力.....(默)
我有時候很愛用 XDrz debug 法
printf("XD");
/* do many things */
printf("rzn");
 如果沒身體就是某個地方爆掉了XD


                    XD 
                       
                  也是一招
老師:「努力是會有回報的!
...........多寫一個功能加10分」
你又開始努力....
/*¶®•§jæ«∏Í∞T§uµ{æ«®t98Ø≈§AØZ≤¶•…¨u æ«∏π°GF74942294*/                           *      *            *         *         printf("h2°G");                  *      node *a, *b, *c;
                                                                                 *      *            *         *         print_list(h2);                  *      if(h==NULL || h->next==NULL) return h;
/                                                                                *      *            *         *         h = Merge(h1, h2);               *      a = h;
******************************************************************************   *      *            *         *         h1 = h2 = NULL;                  *      b = a->next;
*                                                                                *      *            *         *         break;                           *      c = b->next;
FileName: hw7_s.c                                                                *      *            *         case 7:                                    *      a->next = NULL;
Programmer: CrBoy                                                                *      *            *         *         if(order) Split(&h, &h1, &h2);   *      while(c!=NULL){
Purpose: ≥–≥y§@≠”singly linked list®√∞ı¶Ê¶U∫ÿ•Ø‡                                *      *            *         *         else{                            *      *            b->next = a;
Input:                                                                           *      *            *         *         *         h = Reverse(h);        *      *            a = b;
Output: the standard out                                                         *      *            *         *         *         Split(&h, &h1, &h2);   *      *            b = c;
Compilation: gcc hw7_s.c -o hw7_s                                                *      *            *         *         }                                *      *            c = c->next;
Run: ./hw7_s                                                                     *      *            *         *         printf("h1°G");                  *      }
Date: 2006/1/8                                                                   *      *            *         *         print_list(h1);                  *      b->next = a;
/                                                                                *      *            *         *         printf("h2°G");                  *      order = !order;
******************************************************************************   *      *            *         *         print_list(h2);                  *      return b;
/                                                                                *      *            *         *         break;                           }
                                                                                 *      *            *         default: printf("±z™∫øȧJ¶≥ª~°In");
#include <stdio.h>                                                               *      *            *         case 8: help();                            node *Merge(node *h1, node *h2){
                                                                                 *      *            }                                                    *       node *h, *temp;
struct node{                                                                     *      }                                                                 *       h = temp = h1->data < h2->data ? h1 : h2;
*       int data;                                                                *      return 0;                                                         *       h1->data < h2->data ? (h1=h1->next) : (h2=h2->next);
*       struct node *next;                                                       }                                                                        *       while(h1!=NULL && h2!=NULL){
};                                                                                                                                                        *      *            temp = temp->next = h1->data < h2->data ? h1 : h2;
                                                                                 void print_list(node *h){                                                *      *            h1->data < h2->data ? (h1=h1->next) : (h2=h2->next);
typedef struct node node;                                                        *       node *temp;                                                      *       }
                                                                                 *       temp = h;                                                        *       h2 == NULL ? (temp->next=h1) : (temp->next=h2);
void print_list(node*);/*print_list(h); ¶C¶L•Hh∂}¿Y™∫linked list*/               *       while(temp != NULL){                                             *       return h;
node *Insert(int, node*);/*Insert(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥            *      *            printf("%d -> ", temp->data);                        }
°§Jdata®√¶^∂«∑s™∫h*/                                                             *      *            temp = temp->next;
node *Delete(int, node*);/*Delete(data, h); ¶b•Hh∂}¿Y™∫linked list§§ßR∞          *       }                                                                void Split(node **h, node **h1_ptr, node **h2_ptr){
£data®√¶^∂«∑s™∫h*/                                                               *       printf("NULLn");                                                *       node *h1=NULL, *h2=NULL;
node *Search(int, node*);/*Search(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥Mß          }                                                                        *       while(*h!=NULL){
‰data®√∂«¶^data©“¶b™∫¶Ï∏m*/                                                                                                                               *      *            if((*h)->data%2){
int Count(node*);/*Count(h); ≠p∫‚•Hh∂}¿Y™∫linked list§§™∫∏`¬I≠”º∆*/              node *Insert(int data, node *h){                                         *      *            *         if(h1==NULL) h1 = *h1_ptr = *h;
node *Reverse(node*);/*Reverse(h); §œß«±∆¶C•Hh∂}¿Y™∫linked list®√∂«¶^∑s™∫h*/     *       node *p, *t, *temp;                                              *      *            *         else *h1_ptr = (*h1_ptr)->next = *h;
node *Merge(node*, node*);/*Merge(h1, h2); ¶X®÷h1ªPh2≥o2≠”linked                 *       if(h==NULL){                                                     *      *            }else{
list®√¶^∂«¶X®÷´·™∫™∫head*/                                                       *      *             temp = (node*)malloc(sizeof(node));                 *      *            *         if(h2==NULL) h2 = *h2_ptr = *h;
void Split(node**, node**, node**);/*Split(&h, &h1, &h2); §¿≥Œh≥o≠”linked        *      *             temp->data = data;                                  *      *            *         else *h2_ptr = (*h2_ptr)->next = *h;
list¨∞©_∞∏º∆®√§¿ßO¶s®Ïh1ªPh2§§*/                                                 *      *             temp->next = NULL;                                  *      *            }
void help();                                                                     *      *             return temp;                                        *      *            *h = (*h)->next;
                                                                                 *       }                                                                *       }
int order=1;                                                                     *       p = h;                                                           *       (*h1_ptr)->next = (*h2_ptr)->next = NULL;
                                                                                 *       t = h->next;                                                     *       *h1_ptr = h1;
int main(void){                                                                  *       if(data<p->data){                                                *       *h2_ptr = h2;
*       int sel=8, data=0;                                                       *      *             temp = (node*)malloc(sizeof(node));                 *       *h = NULL;
*       node *h=NULL, *h1=NULL, *h2=NULL;                                        *      *             temp->data = data;                                  }
*       help();                                                                  *      *             temp->next = p;
*       while(sel){                                                              *      *             return temp;                                        void help(){
*      *            printf("n•ÿ´e™∫Linked list°G");                             *       }                                                                *       printf("0.µ≤ßÙn");
*      *            print_list(h);                                               *       if(t!=NULL)                                                      *       printf("1.Insertn");
*      *            printf("Ω–øÔ拕؇°G");                                     *      *             while(data<p->data || data>t->data){                *       printf("2.Deleten");
*      *            if(scanf("%d", &sel)==0){                                    *      *            *          p = p->next;                              *       printf("3.Searchn");
*      *            *         sel=-1;                                            *      *            *          t = t->next;                              *       printf("4.Countn");
*      *            *         fflush(stdin);                                     *      *            *          if(t==NULL) break;                        *       printf("5.Reversen");
*      *            }                                                            *      *             }                                                   *       printf("6.Mergen");
*      *            switch(sel){                                                 *       temp = (node*)malloc(sizeof(node));                              *       printf("7.Splitn");
*      *            *         case 0: break;                                     *       temp->data = data;                                               *       printf("8.helpn");
*      *            *         case 1:                                            *       temp->next = p->next;                                            }
*      *            *         *         printf("Ω–øȧJ±˝¥°§J™∫愺∆≠»°G");        *       p->next = temp;
*      *            *         *         if(scanf("%d", &data)==0) continue;      *       return h;
*      *            *         *         if(order)                                }
*      *            *         *         *         h = Insert(data, h);
*      *            *         *         else{                                    node *Delete(int data, node *h){
*      *            *         *         *         h = Reverse(h);                *       node *p, *t;
*      *            *         *         *         h = Insert(data, h);           *       if(h==NULL) return h;
*      *            *         *         *         h = Reverse(h);                *       p = h;
*      *            *         *         }                                        *       t = h->next;
*      *            *         *         break;                                   *       if(data == p->data){
*      *            *         case 2:                                            *      *             p = p->next;
*      *            *         *         printf("Ω–øȧJ±˝ßR∞£™∫愺∆≠»°G");        *      *             free(h);
*      *            *         *         if(scanf("%d", &data)==0) continue;      *      *             return p;
*      *            *         *         if(order)                                *       }
*      *            *         *         *         h = Delete(data, h);           *       while(data!=t->data){
*      *            *         *         else{                                    *      *             p = p->next;
*      *            *         *         *         h = Reverse(h);                *      *             t = t->next;
*      *            *         *         *         h = Delete(data, h);           *      *             if(t==NULL) return h;
*      *            *         *         *         h = Reverse(h);                *       }
*      *            *         *         }                                        *       p->next = t->next;
*      *            *         *         break;                                   *       free(t);
*      *            *         case 3:                                            *       return h;
*      *            *         *         printf("Ω–øȧJ±˝∑j¥M™∫愺∆≠»°G");        }
*      *            *         *         if(scanf("%d", &data)==0) continue;
*      *            *         *         h1 = Search(data, h);                    node *Search(int data, node *h){
*      *            *         *         printf("•H%dß@¨∞∞_¬I™∫Linked list°G",    *       node *p=h;
data);                                                                           *       while(p!=NULL && data!=p->data)* p = p->next;
*      *            *         *         print_list(h1);                          *       return p;
*      *            *         *         h1 = NULL;                               }
*      *            *         *         break;
*      *            *         case 4:                                            int Count(node *h){
*      *            *         *         printf("•ÿ´e™∫Linked list¶@¶≥%d≠”node    *       int count=0;
°Cn", Count(h));                                                                *       while(h!=NULL){
*      *            *         *         break;                                   *      *             count += 1;
*      *            *         case 5:                                            *      *             h = h->next;
*      *            *         *         h = Reverse(h);                          *       }
*      *            *         *         break;                                   *       return count;
*      *            *         case 6:                                            }
*      *            *         *         printf("h1°G");
*      *            *         *         print_list(h1);                          node *Reverse(node *h){
/*¶®•§jæ«∏Í∞T§uµ{æ«®t98Ø≈§AØZ≤¶•…¨u æ«∏π°GF74942294*/                           *        *           *         *         printf("•H%dß@¨∞∞_¬I™∫Linked list°G",    *       return h;
                                                                                 data);                                                                            }
/                                                                                *        *            *         *         print_list(h1);
******************************************************************************   *        *            *         *         h1 = NULL;                              node *Search(int data, node *h){
*                                                                                *        *            *         *         break;                                  *       node *p=h;
FileName: hw7_s.c                                                                *        *            *         case 4:                                           *       while(p!=NULL && data!=p->data)* p = p->next;
Programmer: CrBoy                                                                *        *            *         *         printf("•ÿ´e™∫Linked list¶@¶≥%d≠”node   *       return p;
Purpose: ≥–≥y§@≠”singly linked list®√∞ı¶Ê¶U∫ÿ•Ø‡                                °Cn",   Count(h));                                                               }
Input:                                                                           *        *            *         *         break;
Output: the standard out                                                         *        *            *         case 5:                                           int Count(node *h){
Compilation: gcc hw7_s.c -o hw7_s                                                *        *            *         *         h = Reverse(h);                         *       int count=0;
Run: ./hw7_s                                                                     *        *            *         *         break;                                  *       while(h!=NULL){
Date: 2006/1/8                                                                   *        *            *         case 6:                                           *      *             count += 1;
/                                                                                *        *            *         *         printf("h1°G");                         *      *             h = h->next;
******************************************************************************   *        *            *         *         print_list(h1);                         *       }
/                                                                                *        *            *         *         printf("h2°G");                         *       return count;
                                                                                 *        *            *         *         print_list(h2);                         }
#include <stdio.h>                                                               *        *            *         *         h = Merge(h1, h2);
                                                                                 *        *            *         *         h1 = h2 = NULL;                         node *Reverse(node *h){
struct node{                                                                     *        *            *         *         break;                                  *       node *a, *b, *c;
*       int data;                                                                *        *            *         case 7:                                           *       if(h==NULL || h->next==NULL) return h;
*       struct node *next;                                                       *        *            *         *         if(order) Split(&h, &h1, &h2);          *       a = h;
};                                                                               *        *            *         *         else{                                   *       b = a->next;
                                                                                 *        *            *         *         *         h = Reverse(h);               *       c = b->next;
typedef struct node node;                                                        *        *            *         *         *         Split(&h, &h1, &h2);          *       a->next = NULL;




                                                                                                   新增!
                                                                                 *        *            *         *         }                                       *       while(c!=NULL){
void print_list(node*);/*print_list(h); ¶C¶L•Hh∂}¿Y™∫linked list*/               *        *            *         *         printf("h1°G");                         *      *             b->next = a;
node *Insert(int, node*);/*Insert(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥            *        *            *         *         print_list(h1);                         *      *             a = b;
°§Jdata®√¶^∂«∑s™∫h*/                                                             *        *            *         *         printf("h2°G");                         *      *             b = c;
node *Delete(int, node*);/*Delete(data, h); ¶b•Hh∂}¿Y™∫linked list§§ßR∞          *        *            *         *         print_list(h2);                         *      *             c = c->next;
£data®√¶^∂«∑s™∫h*/                                                               *        *            *         *         break;                                  *       }
node *Search(int, node*);/*Search(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥Mß          *        *            *         default: printf("±z™∫øȧJ¶≥ª~°In");              *       b->next = a;
‰data®√∂«¶^data©“¶b™∫¶Ï∏m*/                                                      *        *            *         case 8: help();                                   *       order = !order;




                              新增!
int Count(node*);/*Count(h); ≠p∫‚•Hh∂}¿Y™∫linked list§§™∫∏`¬I≠”º∆*/              *        *            }                                                           *       return b;
node *Reverse(node*);/*Reverse(h); §œß«±∆¶C•Hh∂}¿Y™∫linked list®√∂«¶^∑s™∫h*/     *         }                                                                       }
node *Merge(node*, node*);/*Merge(h1, h2); ¶X®÷h1ªPh2≥o2≠”linked                 !         temp = (node*)malloc(sizeof(node));
list®√¶^∂«¶X®÷´·™∫™∫head*/                                                       !         temp->data = data;                                                      node *Merge(node *h1, node *h2){
void Split(node**, node**, node**);/*Split(&h, &h1, &h2); §¿≥Œh≥o≠”linked        !         temp->next = p->next;                                                   *       node *h, *temp;
list¨∞©_∞∏º∆®√§¿ßO¶s®Ïh1ªPh2§§*/                                                 !         p->next = temp;                                                         *       h = temp = h1->data < h2->data ? h1 : h2;
void help();                                                                     *         return 0;                                                               *       h1->data < h2->data ? (h1=h1->next) : (h2=h2->next);
                                                                                 }                                                                                 *       while(h1!=NULL && h2!=NULL){
int order=1;                                                                                                                                                       *      *            temp = temp->next = h1->data < h2->data ? h1 : h2;
                                                                                 void print_list(node *h){                                                         *      *            h1->data < h2->data ? (h1=h1->next) : (h2=h2->next);
int main(void){                                                                  *       node *temp;                                                               *       }
!       node *h1=NULL, *h2=NULL;                                                 *       temp = h;                                                                 *       h2 == NULL ? (temp->next=h1) : (temp->next=h2);
!       while(*h!=NULL){                                                         *       while(temp != NULL){                                                      *       return h;
!      !            if((*h)->data%2){                                            *      *            printf("%d -> ", temp->data);                                 }
!      !            !         if(h1==NULL) h1 = *h1_ptr = *h;                    *      *            temp = temp->next;
!      !            !         else *h1_ptr = (*h1_ptr)->next = *h;               *       }                                                                         void Split(node **h, node **h1_ptr, node **h2_ptr){
!      !            }else{                                                       *       printf("NULLn");                                                         *       node *h1=NULL, *h2=NULL;
!      !            !         if(h2==NULL) h2 = *h2_ptr = *h;                    }                                                                                 *       while(*h!=NULL){
!      !            !         else *h2_ptr = (*h2_ptr)->next = *h;                                                                                                 *      *            if((*h)->data%2){
!      !            }                                                            node *Insert(int data, node *h){                                                  *      *            *         if(h1==NULL) h1 = *h1_ptr = *h;
!      !            *h = (*h)->next;                                             *       node *p, *t, *temp;                                                       *      *            *         else *h1_ptr = (*h1_ptr)->next = *h;
!       }                                                                        *       if(h==NULL){                                                              *      *            }else{
!       (*h1_ptr)->next = (*h2_ptr)->next = NULL;                                *      *             temp = (node*)malloc(sizeof(node));                          *      *            *         if(h2==NULL) h2 = *h2_ptr = *h;
!       *h1_ptr = h1;                                                            *      *             temp->data = data;                                           *      *            *         else *h2_ptr = (*h2_ptr)->next = *h;
!       *h2_ptr = h2;                                                            *      *             temp->next = NULL;                                           *      *            }
!       *h = NULL;                                                               *      *             return temp;                                                 *      *            *h = (*h)->next;
*       int sel=8, data=0;                                                       *       }                                                                         *       }
*       node *h=NULL, *h1=NULL, *h2=NULL;                                        *       p = h;                                                                    *       (*h1_ptr)->next = (*h2_ptr)->next = NULL;
*       help();                                                                  *       t = h->next;                                                              *       *h1_ptr = h1;
*       while(sel){                                                              *       if(data<p->data){                                                         *       *h2_ptr = h2;
*      *            printf("n•ÿ´e™∫Linked list°G");                             *      *             temp = (node*)malloc(sizeof(node));                          *       *h = NULL;
*      *            print_list(h);                                               *      *             temp->data = data;                                           }
*      *            printf("Ω–øÔ拕؇°G");                                     *      *             temp->next = p;
*      *            if(scanf("%d", &sel)==0){                                    *      *             return temp;                                                 void help(){
*      *            *         sel=-1;                                            *       }                                                                         *       printf("0.µ≤ßÙn");
*      *            *         fflush(stdin);                                     *       if(t!=NULL)                                                               *       printf("1.Insertn");
*      *            }                                                            *      *             while(data<p->data || data>t->data){                         *       printf("2.Deleten");
*      *            switch(sel){                                                 *      *            *          p = p->next;                                       *       printf("3.Searchn");
*      *            *         case 0: break;                                     *      *            *          t = t->next;                                       *       printf("4.Countn");
*      *            *         case 1:                                            *      *            *          if(t==NULL) break;                                 *       printf("5.Reversen");
*      *            *         *         printf("Ω–øȧJ±˝¥°§J™∫愺∆≠»°G");        *      *             }                                                            *       printf("6.Mergen");
*      *            *         *         if(scanf("%d", &data)==0) continue;      *       temp = (node*)malloc(sizeof(node));                                       *       printf("7.Splitn");
*      *            *         *         if(order)                                *       temp->data = data;                                                        *       printf("8.helpn");
*      *            *         *         *         h = Insert(data, h);           *       temp->next = p->next;                                                     }
*      *            *         *         else{                                    *       p->next = temp;
*      *            *         *         *         h = Reverse(h);                *       return h;
*      *            *         *         *         h = Insert(data, h);           }
*      *            *         *         *         h = Reverse(h);
*      *            *         *         }                                        node *Delete(int data, node *h){
*      *            *         *         break;                                   *       node *p, *t;
*      *            *         case 2:                                            *       if(h==NULL) return h;
*      *            *         *         printf("Ω–øȧJ±˝ßR∞£™∫愺∆≠»°G");        *       p = h;
*      *            *         *         if(scanf("%d", &data)==0) continue;      *       t = h->next;
*      *            *         *         if(order)                                *       if(data == p->data){
*      *            *         *         *         h = Delete(data, h);           *      *             p = p->next;
*      *            *         *         else{                                    *      *             free(h);
*      *            *         *         *         h = Reverse(h);                *      *             return p;
*      *            *         *         *         h = Delete(data, h);           *       }
*      *            *         *         *         h = Reverse(h);                *       while(data!=t->data){
*      *            *         *         }                                        *      *             p = p->next;
*      *            *         *         break;                                   *      *             t = t->next;
*      *            *         case 3:                                            *      *             if(t==NULL) return h;
*      *            *         *         printf("Ω–øȧJ±˝∑j¥M™∫愺∆≠»°G");        *       }
*      *            *         *         if(scanf("%d", &data)==0) continue;      *       p->next = t->next;
*      *            *         *         h1 = Search(data, h);                    *       free(t);
/*¶®•§jæ«∏Í∞T§uµ{æ«®t98Ø≈§AØZ≤¶•…¨u æ«∏π°GF74942294*/                           *        *           *         *         printf("•H%dß@¨∞∞_¬I™∫Linked list°G",    *       return h;
                                                                                 data);                                                                            }
/                                                                                *        *            *         *         print_list(h1);
******************************************************************************   *        *            *         *         h1 = NULL;                              node *Search(int data, node *h){
*                                                                                *        *            *         *         break;                                  *       node *p=h;
FileName: hw7_s.c                                                                *        *            *         case 4:                                           *       while(p!=NULL && data!=p->data)* p = p->next;
Programmer: CrBoy                                                                *        *            *         *         printf("•ÿ´e™∫Linked list¶@¶≥%d≠”node   *       return p;
Purpose: ≥–≥y§@≠”singly linked list®√∞ı¶Ê¶U∫ÿ•Ø‡                                °Cn",   Count(h));                                                               }
Input:                                                                           *        *            *         *         break;
Output: the standard out                                                         *        *            *         case 5:                                           int Count(node *h){
Compilation: gcc hw7_s.c -o hw7_s                                                *        *            *         *         h = Reverse(h);                         *       int count=0;
Run: ./hw7_s                                                                     *        *            *         *         break;                                  *       while(h!=NULL){
Date: 2006/1/8                                                                   *        *            *         case 6:                                           *      *             count += 1;
/                                                                                *        *            *         *         printf("h1°G");                         *      *             h = h->next;
******************************************************************************   *        *            *         *         print_list(h1);                         *       }




                                                                                                                                                                   刪除!
/                                                                                *        *            *         *         printf("h2°G");                         *       return count;
                                                                                 *        *            *         *         print_list(h2);                         }
#include <stdio.h>                                                               *        *            *         *         h = Merge(h1, h2);
                                                                                 *        *            *         *         h1 = h2 = NULL;                         node *Reverse(node *h){
struct node{                                                                     *        *            *         *         break;                                  *       node *a, *b, *c;
*       int data;                                                                *        *            *         case 7:                                           *       if(h==NULL || h->next==NULL) return h;
*       struct node *next;                                                       *        *            *         *         if(order) Split(&h, &h1, &h2);          *       a = h;
};                                                                               *        *            *         *         else{                                   *       b = a->next;
                                                                                 *        *            *         *         *         h = Reverse(h);               *       c = b->next;
typedef struct node node;                                                        *        *            *         *         *         Split(&h, &h1, &h2);          *       a->next = NULL;
                                                                                 *        *            *         *         }                                       !       while(c!=NULL){
void print_list(node*);/*print_list(h); ¶C¶L•Hh∂}¿Y™∫linked list*/               *        *            *         *         printf("h1°G");                         !      !             b->next = a;
node *Insert(int, node*);/*Insert(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥            *        *            *         *         print_list(h1);                         !      !             a = b;
°§Jdata®√¶^∂«∑s™∫h*/                                                             *        *            *         *         printf("h2°G");                         !      !             b = c;
node *Delete(int, node*);/*Delete(data, h); ¶b•Hh∂}¿Y™∫linked list§§ßR∞          *        *            *         *         print_list(h2);                         !      !             c = c->next;
£data®√¶^∂«∑s™∫h*/                                                               *        *            *         *         break;                                  !       }
node *Search(int, node*);/*Search(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥Mß          *        *            *         default: printf("±z™∫øȧJ¶≥ª~°In");              *       b->next = a;
‰data®√∂«¶^data©“¶b™∫¶Ï∏m*/                                                      *        *            *         case 8: help();                                   *       order = !order;
int Count(node*);/*Count(h); ≠p∫‚•Hh∂}¿Y™∫linked list§§™∫∏`¬I≠”º∆*/              *        *            }                                                           *       return b;
node *Reverse(node*);/*Reverse(h); §œß«±∆¶C•Hh∂}¿Y™∫linked list®√∂«¶^∑s™∫h*/     *         }                                                                       }
node *Merge(node*, node*);/*Merge(h1, h2); ¶X®÷h1ªPh2≥o2≠”linked                 !         temp = (node*)malloc(sizeof(node));
list®√¶^∂«¶X®÷´·™∫™∫head*/                                                       !         temp->data = data;                                                      node *Merge(node *h1, node *h2){
void Split(node**, node**, node**);/*Split(&h, &h1, &h2); §¿≥Œh≥o≠”linked        !         temp->next = p->next;                                                   *       node *h, *temp;
list¨∞©_∞∏º∆®√§¿ßO¶s®Ïh1ªPh2§§*/                                                 !         p->next = temp;                                                         *       h = temp = h1->data < h2->data ? h1 : h2;
void help();                                                                     *         return 0;                                                               *       h1->data < h2->data ? (h1=h1->next) : (h2=h2->next);
                                                                                 }                                                                                 *       while(h1!=NULL && h2!=NULL){
int order=1;                                                                                                                                                       *      *            temp = temp->next = h1->data < h2->data ? h1 : h2;
                                                                                 void print_list(node *h){                                                         *      *            h1->data < h2->data ? (h1=h1->next) : (h2=h2->next);
int main(void){                                                                  *       node *temp;                                                               *       }
!       node *h1=NULL, *h2=NULL;                                                 *       temp = h;                                                                 !       while(c!=NULL){
!       while(*h!=NULL){                                                         *       while(temp != NULL){                                                      !      !            b->next = a;
!      !            if((*h)->data%2){                                            *      *            printf("%d -> ", temp->data);                                 !      !            a = b;
!      !            !         if(h1==NULL) h1 = *h1_ptr = *h;                    *      *            temp = temp->next;                                            !      !            b = c;
!      !            !         else *h1_ptr = (*h1_ptr)->next = *h;               *       }                                                                         !      !            c = c->next;
!      !            }else{                                                       *       printf("NULLn");                                                         !       }
!      !            !         if(h2==NULL) h2 = *h2_ptr = *h;                    }                                                                                 *       h2 == NULL ? (temp->next=h1) : (temp->next=h2);
!      !            !         else *h2_ptr = (*h2_ptr)->next = *h;                                                                                                 *       return h;
!      !            }                                                            node *Insert(int data, node *h){                                                  }




                                                                                                                                                              新增!
!      !            *h = (*h)->next;                                             *       node *p, *t, *temp;
!       }                                                                        *       if(h==NULL){                                                              void Split(node **h, node **h1_ptr, node **h2_ptr){
!       (*h1_ptr)->next = (*h2_ptr)->next = NULL;                                *      *             temp = (node*)malloc(sizeof(node));                          *       node *h1=NULL, *h2=NULL;
!       *h1_ptr = h1;                                                            *      *             temp->data = data;                                           *       while(*h!=NULL){
!       *h2_ptr = h2;                                                            *      *             temp->next = NULL;                                           *      *            if((*h)->data%2){
!       *h = NULL;                                                               *      *             return temp;                                                 *      *            *         if(h1==NULL) h1 = *h1_ptr = *h;
*       int sel=8, data=0;                                                       *       }                                                                         *      *            *         else *h1_ptr = (*h1_ptr)->next = *h;
*       node *h=NULL, *h1=NULL, *h2=NULL;                                        *       p = h;                                                                    *      *            }else{
*       help();                                                                  *       t = h->next;                                                              *      *            *         if(h2==NULL) h2 = *h2_ptr = *h;
*       while(sel){                                                              *       if(data<p->data){                                                         *      *            *         else *h2_ptr = (*h2_ptr)->next = *h;
*      *            printf("n•ÿ´e™∫Linked list°G");                             *      *             temp = (node*)malloc(sizeof(node));                          *      *            }
*      *            print_list(h);                                               *      *             temp->data = data;                                           *      *            *h = (*h)->next;
*      *            printf("Ω–øÔ拕؇°G");                                     *      *             temp->next = p;                                              *       }
*      *            if(scanf("%d", &sel)==0){                                    *      *             return temp;                                                 *       (*h1_ptr)->next = (*h2_ptr)->next = NULL;
*      *            *         sel=-1;                                            *       }                                                                         *       *h1_ptr = h1;
*      *            *         fflush(stdin);                                     *       if(t!=NULL)                                                               *       *h2_ptr = h2;
*      *            }                                                            *      *             while(data<p->data || data>t->data){                         *       *h = NULL;
*      *            switch(sel){                                                 *      *            *          p = p->next;                                       }
*      *            *         case 0: break;                                     *      *            *          t = t->next;
*      *            *         case 1:                                            *      *            *          if(t==NULL) break;                                 void help(){
*      *            *         *         printf("Ω–øȧJ±˝¥°§J™∫愺∆≠»°G");        *      *             }                                                            *       printf("0.µ≤ßÙn");
*      *            *         *         if(scanf("%d", &data)==0) continue;      *       temp = (node*)malloc(sizeof(node));                                       *       printf("1.Insertn");
*      *            *         *         if(order)                                *       temp->data = data;                                                        *       printf("2.Deleten");
*      *            *         *         *         h = Insert(data, h);           *       temp->next = p->next;                                                     *       printf("3.Searchn");
*      *            *         *         else{                                    *       p->next = temp;                                                           *       printf("4.Countn");
*      *            *         *         *         h = Reverse(h);                *       return h;                                                                 *       printf("5.Reversen");
*      *            *         *         *         h = Insert(data, h);           }                                                                                 *       printf("6.Mergen");
*      *            *         *         *         h = Reverse(h);                                                                                                  *       printf("7.Splitn");
*      *            *         *         }                                        node *Delete(int data, node *h){                                                  *       printf("8.helpn");
*      *            *         *         break;                                   *       node *p, *t;                                                              }
*      *            *         case 2:                                            *       if(h==NULL) return h;
*      *            *         *         printf("Ω–øȧJ±˝ßR∞£™∫愺∆≠»°G");        *       p = h;
*      *            *         *         if(scanf("%d", &data)==0) continue;      *       t = h->next;
*      *            *         *         if(order)                                *       if(data == p->data){
*      *            *         *         *         h = Delete(data, h);           *      *             p = p->next;
*      *            *         *         else{                                    *      *             free(h);
*      *            *         *         *         h = Reverse(h);                *      *             return p;
*      *            *         *         *         h = Delete(data, h);           *       }
*      *            *         *         *         h = Reverse(h);                *       while(data!=t->data){
*      *            *         *         }                                        *      *             p = p->next;
*      *            *         *         break;                                   *      *             t = t->next;
*      *            *         case 3:                                            *      *             if(t==NULL) return h;
*      *            *         *         printf("Ω–øȧJ±˝∑j¥M™∫愺∆≠»°G");        *       }
*      *            *         *         if(scanf("%d", &data)==0) continue;      *       p->next = t->next;
*      *            *         *         h1 = Search(data, h);                    *       free(t);
/*¶®•§jæ«∏Í∞T§uµ{æ«®t98Ø≈§AØZ≤¶•…¨u æ«∏π°GF74942294*/                           *        *           *         *         printf("•H%dß@¨∞∞_¬I™∫Linked list°G",    *      *           p = p->next;
                                                                                 data);                                                                            *      *           t = t->next;
/                                                                                *        *            *         *         print_list(h1);                         *      *           if(t==NULL) return h;
******************************************************************************   *        *            *         *         h1 = NULL;                              *      }
*                                                                                *        *            *         *         break;                                  *      p->next = t->next;
FileName: hw7_s.c                                                                *        *            *         case 4:                                           *      free(t);
Programmer: CrBoy                                                                *        *            *         *         printf("•ÿ´e™∫Linked list¶@¶≥%d≠”node   *      return h;
Purpose: ≥–≥y§@≠”singly linked list®√∞ı¶Ê¶U∫ÿ•Ø‡                                °Cn",   Count(h));                                                               }
Input:                                                                           *        *            *         *         break;
Output: the standard out                                                         *        *            *         case 5:                                           node *Search(int data, node *h){




                                                                                                                     刪除!
Compilation: gcc hw7_s.c -o hw7_s                                                *        *            *         *         h = Reverse(h);                         !       node *p=h;
Run: ./hw7_s                                                                     *        *            *         *         break;                                  !       while(p!=NULL && data!=p->data)! p = p->next;
Date: 2006/1/8                                                                   *        *            *         case 6:                                           !       return p;
/                                                                                *        *            *         *         printf("h1°G");                         }
******************************************************************************   *        *            *         *         print_list(h1);
/                                                                                *        *            *         *         printf("h2°G");                         int Count(node *h){
                                                                                 *        *            *         *         print_list(h2);                         !       int count=0;
#include <stdio.h>                                                               *        *            *         *         h = Merge(h1, h2);                      !       while(h!=NULL){
                                                                                 *        *            *         *         h1 = h2 = NULL;                         !      !             count += 1;
struct node{                                                                     *        *            *         *         break;                                  !      !             h = h->next;
*       int data;                                                                *        *            *         case 7:                                           !       }
*       struct node *next;                                                       *        *            *         *         if(order) Split(&h, &h1, &h2);          !       return count;
};                                                                               *        *            *         *         else{                                   }
                                                                                 *        *            *         *         *         h = Reverse(h);
typedef struct node node;                                                        *        *            *         *         *         Split(&h, &h1, &h2);          node *Reverse(node *h){
                                                                                 *        *            *         *         }                                       *       node *a, *b, *c;
void print_list(node*);/*print_list(h); ¶C¶L•Hh∂}¿Y™∫linked list*/               *        *            *         *         printf("h1°G");                         *       if(h==NULL || h->next==NULL) return h;
node *Insert(int, node*);/*Insert(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥            *        *            *         *         print_list(h1);                         *       a = h;
°§Jdata®√¶^∂«∑s™∫h*/                                                             *        *            *         *         printf("h2°G");                         *       b = a->next;
node *Delete(int, node*);/*Delete(data, h); ¶b•Hh∂}¿Y™∫linked list§§ßR∞          *        *            *         *         print_list(h2);                         *       c = b->next;
£data®√¶^∂«∑s™∫h*/                                                               *        *            *         *         break;                                  *       a->next = NULL;
node *Search(int, node*);/*Search(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥Mß          *        *            *         default: printf("±z™∫øȧJ¶≥ª~°In");              !       while(c!=NULL){
‰data®√∂«¶^data©“¶b™∫¶Ï∏m*/                                                      *        *            *         case 8: help();                                   !      !             b->next = a;
int Count(node*);/*Count(h); ≠p∫‚•Hh∂}¿Y™∫linked list§§™∫∏`¬I≠”º∆*/              *        *            }                                                           !      !             a = b;
node *Reverse(node*);/*Reverse(h); §œß«±∆¶C•Hh∂}¿Y™∫linked list®√∂«¶^∑s™∫h*/     *         }                                                                       !      !             b = c;
node *Merge(node*, node*);/*Merge(h1, h2); ¶X®÷h1ªPh2≥o2≠”linked                 !         temp = (node*)malloc(sizeof(node));                                     !      !             c = c->next;
list®√¶^∂«¶X®÷´·™∫™∫head*/                                                       !         temp->data = data;                                                      !       }
void Split(node**, node**, node**);/*Split(&h, &h1, &h2); §¿≥Œh≥o≠”linked        !         temp->next = p->next;                                                   *       b->next = a;
list¨∞©_∞∏º∆®√§¿ßO¶s®Ïh1ªPh2§§*/                                                 !         p->next = temp;                                                         *       order = !order;
void help();                                                                     *         return 0;                                                               *       return b;
                                                                                 }                                                                                 }
int order=1;
                                                                                 void print_list(node *h){                                                         node *Merge(node *h1, node *h2){
int main(void){                                                                  *       node *temp;                                                               *       node *h, *temp;
!       node *h1=NULL, *h2=NULL;                                                 *       temp = h;                                                                 *       h = temp = h1->data < h2->data ? h1 : h2;
!       while(*h!=NULL){                                                         *       while(temp != NULL){                                                      *       h1->data < h2->data ? (h1=h1->next) : (h2=h2->next);
!      !            if((*h)->data%2){                                            *      *            printf("%d -> ", temp->data);                                 *       while(h1!=NULL && h2!=NULL){
!      !            !         if(h1==NULL) h1 = *h1_ptr = *h;                    *      *            temp = temp->next;                                            *      *            temp = temp->next = h1->data < h2->data ? h1 : h2;
!      !            !         else *h1_ptr = (*h1_ptr)->next = *h;               *       }                                                                         *      *            h1->data < h2->data ? (h1=h1->next) : (h2=h2->next);
!      !            }else{                                                       *       printf("NULLn");                                                         *       }
!      !            !         if(h2==NULL) h2 = *h2_ptr = *h;                    }                                                                                 !       while(c!=NULL){
!      !            !         else *h2_ptr = (*h2_ptr)->next = *h;                                                                                                 !      !            b->next = a;
!      !            }                                                            node *Insert(int data, node *h){                                                  !      !            a = b;
!      !            *h = (*h)->next;                                             *       node *p, *t, *temp;                                                       !      !            b = c;
!       }                                                                        *       if(h==NULL){                                                              !      !            c = c->next;
!       (*h1_ptr)->next = (*h2_ptr)->next = NULL;                                *      *             temp = (node*)malloc(sizeof(node));                          !       }
!       *h1_ptr = h1;                                                            *      *             temp->data = data;                                           *       h2 == NULL ? (temp->next=h1) : (temp->next=h2);
!       *h2_ptr = h2;                                                            *      *             temp->next = NULL;                                           *       return h;
!       *h = NULL;                                                               *      *             return temp;                                                 }




                      刪除!
*       int sel=8, data=0;                                                       *       }
*       node *h=NULL, *h1=NULL, *h2=NULL;                                        *       p = h;                                                                    void Split(node **h, node **h1_ptr, node **h2_ptr){
*       help();                                                                  !       (*h1_ptr)->next = (*h2_ptr)->next = NULL;                                 *       node *h1=NULL, *h2=NULL;
*       while(sel){                                                              !       *h1_ptr = h1;                                                             *       while(*h!=NULL){
*      *            printf("n•ÿ´e™∫Linked list°G");                             !       *h2_ptr = h2;                                                             *      *            if((*h)->data%2){
*      *            print_list(h);                                               !       *h = NULL;                                                                *      *            *         if(h1==NULL) h1 = *h1_ptr = *h;
*      *            printf("Ω–øÔ拕؇°G");                                     *       t = h->next;                                                              *      *            *         else *h1_ptr = (*h1_ptr)->next = *h;
*      *            if(scanf("%d", &sel)==0){                                    *       if(data<p->data){                                                         *      *            }else{
*      *            *         sel=-1;                                            *      *             temp = (node*)malloc(sizeof(node));                          *      *            *         if(h2==NULL) h2 = *h2_ptr = *h;




                                                                                                                                      新增!
*      *            *         fflush(stdin);                                     *      *             temp->data = data;                                           *      *            *         else *h2_ptr = (*h2_ptr)->next = *h;
*      *            }                                                            *      *             temp->next = p;                                              *      *            }
*      *            switch(sel){                                                 *      *             return temp;                                                 *      *            *h = (*h)->next;
*      *            *         case 0: break;                                     *       }                                                                         *       }
!      !            !         case 1:                                            *       if(t!=NULL)                                                               *       (*h1_ptr)->next = (*h2_ptr)->next = NULL;
!      !            !         !         printf("Ω–øȧJ±˝¥°§J™∫愺∆≠»°G");        *      *             while(data<p->data || data>t->data){                         *       *h1_ptr = h1;
!      !            !         !         if(scanf("%d", &data)==0) continue;      *      *            *          p = p->next;                                       *       *h2_ptr = h2;
!      !            !         !         if(order)                                *      *            *          t = t->next;                                       *       *h = NULL;
!      !            !         !         !         h = Insert(data, h);           *      *            *          if(t==NULL) break;                                 }
!      !            !         !         else{                                    *      *             }
!      !            !         !         !         h = Reverse(h);                *       temp = (node*)malloc(sizeof(node));                                       void help(){
!      !            !         !         !         h = Insert(data, h);           *       temp->data = data;                                                        *       printf("0.µ≤ßÙn");
!      !            !         !         !         h = Reverse(h);                *       temp->next = p->next;                                                     *       printf("1.Insertn");
!      !            !         !         }                                        *       p->next = temp;                                                           *       printf("2.Deleten");
!      !            !         !         break;                                   !       node *h=NULL, *h1=NULL, *h2=NULL;                                         *       printf("3.Searchn");
!      !            !         case 2:                                            !       help();                                                                   *       printf("4.Countn");
!      !            !         !         printf("Ω–øȧJ±˝ßR∞£™∫愺∆≠»°G");        *       return h;                                                                 *       printf("5.Reversen");
!      !            !         !         if(scanf("%d", &data)==0) continue;      }                                                                                 *       printf("6.Mergen");
!      !            !         !         if(order)                                                                                                                  *       printf("7.Splitn");
!      !            !         !         !         h = Delete(data, h);           node *Delete(int data, node *h){                                                  *       printf("8.helpn");
!      !            !         !         else{                                    *       node *p, *t;                                                              }
!      !            !         !         !         h = Reverse(h);                *       if(h==NULL) return h;
!      !            !         !         !         h = Delete(data, h);           *       p = h;
!      !            !         !         !         h = Reverse(h);                *       t = h->next;
!      !            !         !         }                                        *       if(data == p->data){
!      !            !         !         break;                                   *      *             p = p->next;
*      *            *         case 3:                                            *      *             free(h);
*      *            *         *         printf("Ω–øȧJ±˝∑j¥M™∫愺∆≠»°G");        *      *             return p;
*      *            *         *         if(scanf("%d", &data)==0) continue;      *       }
*      *            *         *         h1 = Search(data, h);                    *       while(data!=t->data){
/*¶®•§jæ«∏Í∞T§uµ{æ«®t98Ø≈§AØZ≤¶•…¨u æ«∏π°GF74942294*/                           *        *           *         *         printf("•H%dß@¨∞∞_¬I™∫Linked list°G",    *      *           p = p->next;
                                                                                 data);                                                                            *      *           t = t->next;
/                                                                                *        *            *         *         print_list(h1);                         *      *           if(t==NULL) return h;
******************************************************************************   *        *            *         *         h1 = NULL;                              *      }
*                                                                                *        *            *         *         break;                                  *      p->next = t->next;
FileName: hw7_s.c                                                                *        *            *         case 4:                                           *      free(t);
Programmer: CrBoy                                                                *        *            *         *         printf("•ÿ´e™∫Linked list¶@¶≥%d≠”node   *      return h;
Purpose: ≥–≥y§@≠”singly linked list®√∞ı¶Ê¶U∫ÿ•Ø‡                                °Cn",   Count(h));                                                               }
Input:                                                                           *        *            *         *         break;
Output: the standard out                                                         *        *            *         case 5:                                           node *Search(int data, node *h){
Compilation: gcc hw7_s.c -o hw7_s                                                *        *            *         *         h = Reverse(h);                         !       node *p=h;
Run: ./hw7_s                                                                     *        *            *         *         break;                                  !       while(p!=NULL && data!=p->data)! p = p->next;
Date: 2006/1/8                                                                   *        *            *         case 6:                                           !       return p;
/                                                                                *        *            *         *         printf("h1°G");                         }
******************************************************************************   *        *            *         *         print_list(h1);
/                                                                                *        *            *         *         printf("h2°G");                         int Count(node *h){
                                                                                 *        *            *         *         print_list(h2);                         !       int count=0;
#include <stdio.h>                                                               *        *            *         *         h = Merge(h1, h2);                      !       while(h!=NULL){
                                                                                 *        *            *         *         h1 = h2 = NULL;                         !      !             count += 1;
struct node{                                                                     *        *            *         *         break;                                  !      !             h = h->next;
*       int data;                                                                *        *            *         case 7:                                           !       }
*       struct node *next;                                                       *        *            *         *         if(order) Split(&h, &h1, &h2);          !       return count;
};                                                                               *        *            *         *         else{                                   }
                                                                                 *        *            *         *         *         h = Reverse(h);
typedef struct node node;                                                        *        *            *         *         *         Split(&h, &h1, &h2);          node *Reverse(node *h){
                                                                                 *        *            *         *         }                                       *       node *a, *b, *c;
void print_list(node*);/*print_list(h); ¶C¶L•Hh∂}¿Y™∫linked list*/               *        *            *         *         printf("h1°G");                         *       if(h==NULL || h->next==NULL) return h;
node *Insert(int, node*);/*Insert(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥            *        *            *         *         print_list(h1);                         *       a = h;
°§Jdata®√¶^∂«∑s™∫h*/                                                             *        *            *         *         printf("h2°G");                         *       b = a->next;
node *Delete(int, node*);/*Delete(data, h); ¶b•Hh∂}¿Y™∫linked list§§ßR∞          *        *            *         *         print_list(h2);                         *       c = b->next;




                                                                                 刪除!
£data®√¶^∂«∑s™∫h*/                                                               *        *            *         *         break;                                  *       a->next = NULL;
node *Search(int, node*);/*Search(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥Mß          *        *            *         default: printf("±z™∫øȧJ¶≥ª~°In");              !       while(c!=NULL){
‰data®√∂«¶^data©“¶b™∫¶Ï∏m*/                                                      *        *            *         case 8: help();                                   !      !             b->next = a;
int Count(node*);/*Count(h); ≠p∫‚•Hh∂}¿Y™∫linked list§§™∫∏`¬I≠”º∆*/              *        *            }                                                           !      !             a = b;
node *Reverse(node*);/*Reverse(h); §œß«±∆¶C•Hh∂}¿Y™∫linked list®√∂«¶^∑s™∫h*/     *         }                                                                       !      !             b = c;
node *Merge(node*, node*);/*Merge(h1, h2); ¶X®÷h1ªPh2≥o2≠”linked                 !         temp = (node*)malloc(sizeof(node));                                     !      !             c = c->next;
list®√¶^∂«¶X®÷´·™∫™∫head*/                                                       !         temp->data = data;                                                      !       }
void Split(node**, node**, node**);/*Split(&h, &h1, &h2); §¿≥Œh≥o≠”linked        !         temp->next = p->next;                                                   *       b->next = a;
list¨∞©_∞∏º∆®√§¿ßO¶s®Ïh1ªPh2§§*/                                                 !         p->next = temp;                                                         *       order = !order;
void help();                                                                     *         return 0;                                                               *       return b;
                                                                                 }                                                                                 }
int order=1;
                                                                                 void print_list(node *h){                                                         node *Merge(node *h1, node *h2){
int main(void){                                                                  *       node *temp;                                                               *       node *h, *temp;
!       node *h1=NULL, *h2=NULL;                                                 *       temp = h;                                                                 *       h = temp = h1->data < h2->data ? h1 : h2;
!       while(*h!=NULL){                                                         *       while(temp != NULL){                                                      *       h1->data < h2->data ? (h1=h1->next) : (h2=h2->next);
!      !            if((*h)->data%2){                                            *      *            printf("%d -> ", temp->data);                                 *       while(h1!=NULL && h2!=NULL){
!      !            !         if(h1==NULL) h1 = *h1_ptr = *h;                    *      *            temp = temp->next;                                            *      *            temp = temp->next = h1->data < h2->data ? h1 : h2;
!      !            !         else *h1_ptr = (*h1_ptr)->next = *h;               *       }                                                                         *      *            h1->data < h2->data ? (h1=h1->next) : (h2=h2->next);
!      !            }else{                                                       *       printf("NULLn");                                                         *       }
!      !            !         if(h2==NULL) h2 = *h2_ptr = *h;                    }                                                                                 !       while(c!=NULL){
!      !            !         else *h2_ptr = (*h2_ptr)->next = *h;                                                                                                 !      !            b->next = a;
!      !            }                                                            node *Insert(int data, node *h){                                                  !      !            a = b;
!      !            *h = (*h)->next;                                             *       node *p, *t, *temp;                                                       !      !            b = c;
!       }                                                                        *       if(h==NULL){                                                              !      !            c = c->next;
!       (*h1_ptr)->next = (*h2_ptr)->next = NULL;                                *      *             temp = (node*)malloc(sizeof(node));                          !       }
!       *h1_ptr = h1;                                                            *      *             temp->data = data;                                           *       h2 == NULL ? (temp->next=h1) : (temp->next=h2);
!       *h2_ptr = h2;                                                            *      *             temp->next = NULL;                                           *       return h;
!       *h = NULL;                                                               *      *             return temp;                                                 }
*       int sel=8, data=0;                                                       *       }
*       node *h=NULL, *h1=NULL, *h2=NULL;                                        *       p = h;                                                                    void Split(node **h, node **h1_ptr, node **h2_ptr){
*       help();                                                                  !       (*h1_ptr)->next = (*h2_ptr)->next = NULL;                                 *       node *h1=NULL, *h2=NULL;
*       while(sel){                                                              !       *h1_ptr = h1;                                                             *       while(*h!=NULL){
*      *            printf("n•ÿ´e™∫Linked list°G");                             !       *h2_ptr = h2;                                                             *      *            if((*h)->data%2){
*      *            print_list(h);                                               !       *h = NULL;                                                                *      *            *         if(h1==NULL) h1 = *h1_ptr = *h;
*      *            printf("Ω–øÔ拕؇°G");                                     *       t = h->next;                                                              *      *            *         else *h1_ptr = (*h1_ptr)->next = *h;
*      *            if(scanf("%d", &sel)==0){                                    *       if(data<p->data){                                                         *      *            }else{




                                                                                                                                                  新增!
*      *            *         sel=-1;                                            *      *             temp = (node*)malloc(sizeof(node));                          *      *            *         if(h2==NULL) h2 = *h2_ptr = *h;
*      *            *         fflush(stdin);                                     *      *             temp->data = data;                                           *      *            *         else *h2_ptr = (*h2_ptr)->next = *h;
*      *            }                                                            *      *             temp->next = p;                                              *      *            }
*      *            switch(sel){                                                 *      *             return temp;                                                 *      *            *h = (*h)->next;
*      *            *         case 0: break;                                     *       }                                                                         *       }
!      !            !         case 1:                                            *       if(t!=NULL)                                                               *       (*h1_ptr)->next = (*h2_ptr)->next = NULL;
!      !            !         !         printf("Ω–øȧJ±˝¥°§J™∫愺∆≠»°G");        *      *             while(data<p->data || data>t->data){                         *       *h1_ptr = h1;
!      !            !         !         if(scanf("%d", &data)==0) continue;      *      *            *          p = p->next;                                       *       *h2_ptr = h2;
!      !            !         !         if(order)                                *      *            *          t = t->next;                                       *       *h = NULL;
!      !            !         !         !         h = Insert(data, h);           *      *            *          if(t==NULL) break;                                 }
!      !            !         !         else{                                    *      *             }
!      !            !         !         !         h = Reverse(h);                *       temp = (node*)malloc(sizeof(node));                                       void print_list(node *h){
!      !            !         !         !         h = Insert(data, h);           *       temp->data = data;                                                        !       node *temp;
!      !            !         !         !         h = Reverse(h);                *       temp->next = p->next;                                                     !       temp = h;
!      !            !         !         }                                        *       p->next = temp;                                                           !       while(temp != NULL){
!      !            !         !         break;                                   !       node *h=NULL, *h1=NULL, *h2=NULL;                                         !      !            printf("%d -> ", temp->data);
!      !            !         case 2:                                            !       help();                                                                   !      !            temp = temp->next;
!      !            !         !         printf("Ω–øȧJ±˝ßR∞£™∫愺∆≠»°G");        *       return h;                                                                 !       }
!      !            !         !         if(scanf("%d", &data)==0) continue;      }                                                                                 !       printf("NULLn");
!      !            !         !         if(order)                                                                                                                  }
!      !            !         !         !         h = Delete(data, h);           node *Delete(int data, node *h){
!      !            !         !         else{                                    *       node *p, *t;                                                              void help(){
!      !            !         !         !         h = Reverse(h);                *       if(h==NULL) return h;                                                     *       printf("0.µ≤ßÙn");
!      !            !         !         !         h = Delete(data, h);           *       p = h;                                                                    *       printf("1.Insertn");
!      !            !         !         !         h = Reverse(h);                *       t = h->next;                                                              *       printf("2.Deleten");
!      !            !         !         }                                        *       if(data == p->data){                                                      *       printf("3.Searchn");
!      !            !         !         break;                                   *      *             p = p->next;                                                 *       printf("4.Countn");
*      *            *         case 3:                                            *      *             free(h);                                                     *       printf("5.Reversen");
*      *            *         *         printf("Ω–øȧJ±˝∑j¥M™∫愺∆≠»°G");        *      *             return p;                                                    *       printf("6.Mergen");
*      *            *         *         if(scanf("%d", &data)==0) continue;      *       }                                                                         *       printf("7.Splitn");
*      *            *         *         h1 = Search(data, h);                    *       while(data!=t->data){                                                     *       printf("8.helpn");
你花了兩天
結果功能寫爛了
又花兩天把code改回來
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code
Code Smart, Don’t Code Hard: Tips for Writing Better Code

Más contenido relacionado

La actualidad más candente

Assignment no39
Assignment no39Assignment no39
Assignment no39Jay Patel
 
c++ project on restaurant billing
c++ project on restaurant billing c++ project on restaurant billing
c++ project on restaurant billing Swakriti Rathore
 
Numerical Methods with Computer Programming
Numerical Methods with Computer ProgrammingNumerical Methods with Computer Programming
Numerical Methods with Computer ProgrammingUtsav Patel
 
program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)Ankit Gupta
 
Introduction to ATS plugins
Introduction to ATS pluginsIntroduction to ATS plugins
Introduction to ATS pluginsPSUdaemon
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Remy Sharp
 
Nouveau document texte
Nouveau document texteNouveau document texte
Nouveau document texteSai Ef
 
Yy
YyYy
Yyyygh
 
Basic C++ 11/14 for Python Programmers
Basic C++ 11/14 for Python ProgrammersBasic C++ 11/14 for Python Programmers
Basic C++ 11/14 for Python ProgrammersAppier
 
Abusing text/template for data transformation
Abusing text/template for data transformationAbusing text/template for data transformation
Abusing text/template for data transformationArnaud Porterie
 
Tests unitaires pour PostgreSQL avec pgTap
Tests unitaires pour PostgreSQL avec pgTapTests unitaires pour PostgreSQL avec pgTap
Tests unitaires pour PostgreSQL avec pgTapRodolphe Quiédeville
 

La actualidad más candente (19)

Myraytracer
MyraytracerMyraytracer
Myraytracer
 
Ds 2 cycle
Ds 2 cycleDs 2 cycle
Ds 2 cycle
 
Assignment no39
Assignment no39Assignment no39
Assignment no39
 
c++ project on restaurant billing
c++ project on restaurant billing c++ project on restaurant billing
c++ project on restaurant billing
 
Numerical Methods with Computer Programming
Numerical Methods with Computer ProgrammingNumerical Methods with Computer Programming
Numerical Methods with Computer Programming
 
Railwaynew
RailwaynewRailwaynew
Railwaynew
 
program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)
 
Introduction to ATS plugins
Introduction to ATS pluginsIntroduction to ATS plugins
Introduction to ATS plugins
 
Event
EventEvent
Event
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)
 
C99.php
C99.phpC99.php
C99.php
 
Hospital management
Hospital managementHospital management
Hospital management
 
Nouveau document texte
Nouveau document texteNouveau document texte
Nouveau document texte
 
Yy
YyYy
Yy
 
Basic C++ 11/14 for Python Programmers
Basic C++ 11/14 for Python ProgrammersBasic C++ 11/14 for Python Programmers
Basic C++ 11/14 for Python Programmers
 
Ss
SsSs
Ss
 
Abusing text/template for data transformation
Abusing text/template for data transformationAbusing text/template for data transformation
Abusing text/template for data transformation
 
Tests unitaires pour PostgreSQL avec pgTap
Tests unitaires pour PostgreSQL avec pgTapTests unitaires pour PostgreSQL avec pgTap
Tests unitaires pour PostgreSQL avec pgTap
 
Quiz using C++
Quiz using C++Quiz using C++
Quiz using C++
 

Similar a Code Smart, Don’t Code Hard: Tips for Writing Better Code

#include iostream #includestdlib.h using namespace std;str.pdf
#include iostream #includestdlib.h using namespace std;str.pdf#include iostream #includestdlib.h using namespace std;str.pdf
#include iostream #includestdlib.h using namespace std;str.pdflakshmijewellery
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxteyaj1
 
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdfincludestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdfgalagirishp
 
This code currently works... Run it and get a screen shot of its .docx
 This code currently works... Run it and get a screen shot of its .docx This code currently works... Run it and get a screen shot of its .docx
This code currently works... Run it and get a screen shot of its .docxKomlin1
 
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfC++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfaassecuritysystem
 
Data structures cs301 power point slides lecture 03
Data structures   cs301 power point slides lecture 03Data structures   cs301 power point slides lecture 03
Data structures cs301 power point slides lecture 03Nasir Mehmood
 
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docxreverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docxacarolyn
 
C++ Program to Implement Doubly Linked List #includei.pdf
  C++ Program to Implement Doubly Linked List  #includei.pdf  C++ Program to Implement Doubly Linked List  #includei.pdf
C++ Program to Implement Doubly Linked List #includei.pdfLalkamal2
 
Introduction to CUDA C: NVIDIA : Notes
Introduction to CUDA C: NVIDIA : NotesIntroduction to CUDA C: NVIDIA : Notes
Introduction to CUDA C: NVIDIA : NotesSubhajit Sahu
 
computer notes - Data Structures - 3
computer notes - Data Structures - 3computer notes - Data Structures - 3
computer notes - Data Structures - 3ecomputernotes
 
Doubly linklist
Doubly linklistDoubly linklist
Doubly linklistilsamaryum
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxssuser454af01
 
Write a C program that reads the words the user types at the command.pdf
Write a C program that reads the words the user types at the command.pdfWrite a C program that reads the words the user types at the command.pdf
Write a C program that reads the words the user types at the command.pdfSANDEEPARIHANT
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdffantoosh1
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfaathiauto
 
Help to implement delete_node get_succ get_pred walk and.pdf
Help to implement delete_node get_succ get_pred walk and.pdfHelp to implement delete_node get_succ get_pred walk and.pdf
Help to implement delete_node get_succ get_pred walk and.pdfcontact32
 

Similar a Code Smart, Don’t Code Hard: Tips for Writing Better Code (20)

Sbaw091006
Sbaw091006Sbaw091006
Sbaw091006
 
#include iostream #includestdlib.h using namespace std;str.pdf
#include iostream #includestdlib.h using namespace std;str.pdf#include iostream #includestdlib.h using namespace std;str.pdf
#include iostream #includestdlib.h using namespace std;str.pdf
 
C++ programs
C++ programsC++ programs
C++ programs
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
 
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdfincludestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
 
This code currently works... Run it and get a screen shot of its .docx
 This code currently works... Run it and get a screen shot of its .docx This code currently works... Run it and get a screen shot of its .docx
This code currently works... Run it and get a screen shot of its .docx
 
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfC++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
 
Data structures cs301 power point slides lecture 03
Data structures   cs301 power point slides lecture 03Data structures   cs301 power point slides lecture 03
Data structures cs301 power point slides lecture 03
 
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docxreverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docx
 
C program
C programC program
C program
 
C++ Program to Implement Doubly Linked List #includei.pdf
  C++ Program to Implement Doubly Linked List  #includei.pdf  C++ Program to Implement Doubly Linked List  #includei.pdf
C++ Program to Implement Doubly Linked List #includei.pdf
 
Introduction to CUDA C: NVIDIA : Notes
Introduction to CUDA C: NVIDIA : NotesIntroduction to CUDA C: NVIDIA : Notes
Introduction to CUDA C: NVIDIA : Notes
 
computer notes - Data Structures - 3
computer notes - Data Structures - 3computer notes - Data Structures - 3
computer notes - Data Structures - 3
 
Doubly linklist
Doubly linklistDoubly linklist
Doubly linklist
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
 
C++ via C#
C++ via C#C++ via C#
C++ via C#
 
Write a C program that reads the words the user types at the command.pdf
Write a C program that reads the words the user types at the command.pdfWrite a C program that reads the words the user types at the command.pdf
Write a C program that reads the words the user types at the command.pdf
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdf
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
 
Help to implement delete_node get_succ get_pred walk and.pdf
Help to implement delete_node get_succ get_pred walk and.pdfHelp to implement delete_node get_succ get_pred walk and.pdf
Help to implement delete_node get_succ get_pred walk and.pdf
 

Más de 均民 戴

CKmates - AWS 三大 AI 解決方案:應用影像辨識、聊天機器人與語音轉換以及 Serverless 應用
CKmates - AWS 三大 AI 解決方案:應用影像辨識、聊天機器人與語音轉換以及 Serverless 應用CKmates - AWS 三大 AI 解決方案:應用影像辨識、聊天機器人與語音轉換以及 Serverless 應用
CKmates - AWS 三大 AI 解決方案:應用影像辨識、聊天機器人與語音轉換以及 Serverless 應用均民 戴
 
CKmates - AWS 雲端運算 基礎服務介紹
CKmates - AWS 雲端運算 基礎服務介紹CKmates - AWS 雲端運算 基礎服務介紹
CKmates - AWS 雲端運算 基礎服務介紹均民 戴
 
COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境
COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境
COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境均民 戴
 
在 DigitalOcean 架設 Gitlab
在 DigitalOcean 架設 Gitlab在 DigitalOcean 架設 Gitlab
在 DigitalOcean 架設 Gitlab均民 戴
 
Bootstrap個人網站 20141117
Bootstrap個人網站 20141117Bootstrap個人網站 20141117
Bootstrap個人網站 20141117均民 戴
 
Bootstrap個人網站 20141027
Bootstrap個人網站 20141027Bootstrap個人網站 20141027
Bootstrap個人網站 20141027均民 戴
 
資訊創意課程 - Create A Personal Website 1
資訊創意課程 - Create A Personal Website 1資訊創意課程 - Create A Personal Website 1
資訊創意課程 - Create A Personal Website 1均民 戴
 
MIS MySQL 入門
MIS MySQL 入門MIS MySQL 入門
MIS MySQL 入門均民 戴
 
SITCON 2014 - Regular Expression Introduce
SITCON 2014 - Regular Expression IntroduceSITCON 2014 - Regular Expression Introduce
SITCON 2014 - Regular Expression Introduce均民 戴
 
興大資訊社 CPE 訓練宣傳
興大資訊社 CPE 訓練宣傳興大資訊社 CPE 訓練宣傳
興大資訊社 CPE 訓練宣傳均民 戴
 
20130706閃電秀
20130706閃電秀20130706閃電秀
20130706閃電秀均民 戴
 
Drupalize your data use entities
Drupalize your data use entitiesDrupalize your data use entities
Drupalize your data use entities均民 戴
 
Drupal 7 Entity & Entity API
Drupal 7 Entity & Entity APIDrupal 7 Entity & Entity API
Drupal 7 Entity & Entity API均民 戴
 
植基於個人本體論的新聞推薦系統
植基於個人本體論的新聞推薦系統植基於個人本體論的新聞推薦系統
植基於個人本體論的新聞推薦系統均民 戴
 
JSON 和 Android 的火花
JSON 和 Android 的火花JSON 和 Android 的火花
JSON 和 Android 的火花均民 戴
 

Más de 均民 戴 (15)

CKmates - AWS 三大 AI 解決方案:應用影像辨識、聊天機器人與語音轉換以及 Serverless 應用
CKmates - AWS 三大 AI 解決方案:應用影像辨識、聊天機器人與語音轉換以及 Serverless 應用CKmates - AWS 三大 AI 解決方案:應用影像辨識、聊天機器人與語音轉換以及 Serverless 應用
CKmates - AWS 三大 AI 解決方案:應用影像辨識、聊天機器人與語音轉換以及 Serverless 應用
 
CKmates - AWS 雲端運算 基礎服務介紹
CKmates - AWS 雲端運算 基礎服務介紹CKmates - AWS 雲端運算 基礎服務介紹
CKmates - AWS 雲端運算 基礎服務介紹
 
COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境
COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境
COSCUP 2016 Workshop: 用 Docker 架設班級 git-it 練習環境
 
在 DigitalOcean 架設 Gitlab
在 DigitalOcean 架設 Gitlab在 DigitalOcean 架設 Gitlab
在 DigitalOcean 架設 Gitlab
 
Bootstrap個人網站 20141117
Bootstrap個人網站 20141117Bootstrap個人網站 20141117
Bootstrap個人網站 20141117
 
Bootstrap個人網站 20141027
Bootstrap個人網站 20141027Bootstrap個人網站 20141027
Bootstrap個人網站 20141027
 
資訊創意課程 - Create A Personal Website 1
資訊創意課程 - Create A Personal Website 1資訊創意課程 - Create A Personal Website 1
資訊創意課程 - Create A Personal Website 1
 
MIS MySQL 入門
MIS MySQL 入門MIS MySQL 入門
MIS MySQL 入門
 
SITCON 2014 - Regular Expression Introduce
SITCON 2014 - Regular Expression IntroduceSITCON 2014 - Regular Expression Introduce
SITCON 2014 - Regular Expression Introduce
 
興大資訊社 CPE 訓練宣傳
興大資訊社 CPE 訓練宣傳興大資訊社 CPE 訓練宣傳
興大資訊社 CPE 訓練宣傳
 
20130706閃電秀
20130706閃電秀20130706閃電秀
20130706閃電秀
 
Drupalize your data use entities
Drupalize your data use entitiesDrupalize your data use entities
Drupalize your data use entities
 
Drupal 7 Entity & Entity API
Drupal 7 Entity & Entity APIDrupal 7 Entity & Entity API
Drupal 7 Entity & Entity API
 
植基於個人本體論的新聞推薦系統
植基於個人本體論的新聞推薦系統植基於個人本體論的新聞推薦系統
植基於個人本體論的新聞推薦系統
 
JSON 和 Android 的火花
JSON 和 Android 的火花JSON 和 Android 的火花
JSON 和 Android 的火花
 

Último

AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEaurabinda banchhor
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxruthvilladarez
 

Último (20)

AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSE
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docx
 

Code Smart, Don’t Code Hard: Tips for Writing Better Code

  • 1. elease R 寫程式?那些老師沒教的事 Code Smart, Don’t Code Hard 2012/07/15 @StudyArea-Taichung 畢玉泉 (小畢/CrBoy) <crboy@crboy.net>
  • 4. 經歷 2007 年成大資工系程式設計競賽-優等 2007 年全國大專電腦軟體設計競賽甲組-佳作 2007 年 ACM ICPC 亞洲區台灣賽區-第 13 名 2008 年第三屆南區大專院校程式設計競賽-進階組第一名 2008 年成大資工系程式設計競賽進階組-第一名 協辦 Ubuntu-TW 社群全台相關活動 2007 - 迄今 2008 年間,於系內自行主講數場 C 語言基礎觀念教學課程 2008 年全國大專電腦軟體設計競賽甲組-第三名 主講「U很大,U不用錢 - Ubuntu Linux 介紹」於國立成功大學 (http://goo.gl/lEnCN) 2009/03/24 主講「MozTW & Ubuntu 自由新生代」於高雄應用科技大學 (http://goo.gl/CgtBK) 2009/07/13 主講「Ubuntu Linux 簡介」於台南四校資訊社團聯合迎新 2009/10/31 「自由軟體應用與教學」於雲林縣口湖國小 2010/01/21 2010 年台灣駭客年會 場務組工作人員 Ubuntu-TW 社群文件組(Doc Team)負責人 2010/10 - 迄今 2011 年台灣駭客年會 場務組工作人員 2011 年開源人年會 場務組工作人員 2011 年資安技能金盾獎-第三名 主講「那些老師沒教的事 - Code Smart, Don’t Code hard」於國立成功大學 2012/03/29
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18. ??
  • 19.
  • 20.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 37.
  • 38.
  • 39.
  • 41. 我有時候很愛用 XDrz debug 法 printf("XD"); /* do many things */ printf("rzn"); 如果沒身體就是某個地方爆掉了XD XD    也是一招
  • 44. /*¶®•§jæ«∏Í∞T§uµ{æ«®t98Ø≈§AØZ≤¶•…¨u æ«∏π°GF74942294*/ * * * * printf("h2°G"); * node *a, *b, *c; * * * * print_list(h2); * if(h==NULL || h->next==NULL) return h; / * * * * h = Merge(h1, h2); * a = h; ****************************************************************************** * * * * h1 = h2 = NULL; * b = a->next; * * * * * break; * c = b->next; FileName: hw7_s.c * * * case 7: * a->next = NULL; Programmer: CrBoy * * * * if(order) Split(&h, &h1, &h2); * while(c!=NULL){ Purpose: ≥–≥y§@≠”singly linked list®√∞ı¶Ê¶U∫ÿ•Ø‡ * * * * else{ * * b->next = a; Input: * * * * * h = Reverse(h); * * a = b; Output: the standard out * * * * * Split(&h, &h1, &h2); * * b = c; Compilation: gcc hw7_s.c -o hw7_s * * * * } * * c = c->next; Run: ./hw7_s * * * * printf("h1°G"); * } Date: 2006/1/8 * * * * print_list(h1); * b->next = a; / * * * * printf("h2°G"); * order = !order; ****************************************************************************** * * * * print_list(h2); * return b; / * * * * break; } * * * default: printf("±z™∫øȧJ¶≥ª~°In"); #include <stdio.h> * * * case 8: help(); node *Merge(node *h1, node *h2){ * * } * node *h, *temp; struct node{ * } * h = temp = h1->data < h2->data ? h1 : h2; * int data; * return 0; * h1->data < h2->data ? (h1=h1->next) : (h2=h2->next); * struct node *next; } * while(h1!=NULL && h2!=NULL){ }; * * temp = temp->next = h1->data < h2->data ? h1 : h2; void print_list(node *h){ * * h1->data < h2->data ? (h1=h1->next) : (h2=h2->next); typedef struct node node; * node *temp; * } * temp = h; * h2 == NULL ? (temp->next=h1) : (temp->next=h2); void print_list(node*);/*print_list(h); ¶C¶L•Hh∂}¿Y™∫linked list*/ * while(temp != NULL){ * return h; node *Insert(int, node*);/*Insert(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥ * * printf("%d -> ", temp->data); } °§Jdata®√¶^∂«∑s™∫h*/ * * temp = temp->next; node *Delete(int, node*);/*Delete(data, h); ¶b•Hh∂}¿Y™∫linked list§§ßR∞ * } void Split(node **h, node **h1_ptr, node **h2_ptr){ £data®√¶^∂«∑s™∫h*/ * printf("NULLn"); * node *h1=NULL, *h2=NULL; node *Search(int, node*);/*Search(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥Mß } * while(*h!=NULL){ ‰data®√∂«¶^data©“¶b™∫¶Ï∏m*/ * * if((*h)->data%2){ int Count(node*);/*Count(h); ≠p∫‚•Hh∂}¿Y™∫linked list§§™∫∏`¬I≠”º∆*/ node *Insert(int data, node *h){ * * * if(h1==NULL) h1 = *h1_ptr = *h; node *Reverse(node*);/*Reverse(h); §œß«±∆¶C•Hh∂}¿Y™∫linked list®√∂«¶^∑s™∫h*/ * node *p, *t, *temp; * * * else *h1_ptr = (*h1_ptr)->next = *h; node *Merge(node*, node*);/*Merge(h1, h2); ¶X®÷h1ªPh2≥o2≠”linked * if(h==NULL){ * * }else{ list®√¶^∂«¶X®÷´·™∫™∫head*/ * * temp = (node*)malloc(sizeof(node)); * * * if(h2==NULL) h2 = *h2_ptr = *h; void Split(node**, node**, node**);/*Split(&h, &h1, &h2); §¿≥Œh≥o≠”linked * * temp->data = data; * * * else *h2_ptr = (*h2_ptr)->next = *h; list¨∞©_∞∏º∆®√§¿ßO¶s®Ïh1ªPh2§§*/ * * temp->next = NULL; * * } void help(); * * return temp; * * *h = (*h)->next; * } * } int order=1; * p = h; * (*h1_ptr)->next = (*h2_ptr)->next = NULL; * t = h->next; * *h1_ptr = h1; int main(void){ * if(data<p->data){ * *h2_ptr = h2; * int sel=8, data=0; * * temp = (node*)malloc(sizeof(node)); * *h = NULL; * node *h=NULL, *h1=NULL, *h2=NULL; * * temp->data = data; } * help(); * * temp->next = p; * while(sel){ * * return temp; void help(){ * * printf("n•ÿ´e™∫Linked list°G"); * } * printf("0.µ≤ßÙn"); * * print_list(h); * if(t!=NULL) * printf("1.Insertn"); * * printf("Ω–øÔ拕؇°G"); * * while(data<p->data || data>t->data){ * printf("2.Deleten"); * * if(scanf("%d", &sel)==0){ * * * p = p->next; * printf("3.Searchn"); * * * sel=-1; * * * t = t->next; * printf("4.Countn"); * * * fflush(stdin); * * * if(t==NULL) break; * printf("5.Reversen"); * * } * * } * printf("6.Mergen"); * * switch(sel){ * temp = (node*)malloc(sizeof(node)); * printf("7.Splitn"); * * * case 0: break; * temp->data = data; * printf("8.helpn"); * * * case 1: * temp->next = p->next; } * * * * printf("Ω–øȧJ±˝¥°§J™∫愺∆≠»°G"); * p->next = temp; * * * * if(scanf("%d", &data)==0) continue; * return h; * * * * if(order) } * * * * * h = Insert(data, h); * * * * else{ node *Delete(int data, node *h){ * * * * * h = Reverse(h); * node *p, *t; * * * * * h = Insert(data, h); * if(h==NULL) return h; * * * * * h = Reverse(h); * p = h; * * * * } * t = h->next; * * * * break; * if(data == p->data){ * * * case 2: * * p = p->next; * * * * printf("Ω–øȧJ±˝ßR∞£™∫愺∆≠»°G"); * * free(h); * * * * if(scanf("%d", &data)==0) continue; * * return p; * * * * if(order) * } * * * * * h = Delete(data, h); * while(data!=t->data){ * * * * else{ * * p = p->next; * * * * * h = Reverse(h); * * t = t->next; * * * * * h = Delete(data, h); * * if(t==NULL) return h; * * * * * h = Reverse(h); * } * * * * } * p->next = t->next; * * * * break; * free(t); * * * case 3: * return h; * * * * printf("Ω–øȧJ±˝∑j¥M™∫愺∆≠»°G"); } * * * * if(scanf("%d", &data)==0) continue; * * * * h1 = Search(data, h); node *Search(int data, node *h){ * * * * printf("•H%dß@¨∞∞_¬I™∫Linked list°G", * node *p=h; data); * while(p!=NULL && data!=p->data)* p = p->next; * * * * print_list(h1); * return p; * * * * h1 = NULL; } * * * * break; * * * case 4: int Count(node *h){ * * * * printf("•ÿ´e™∫Linked list¶@¶≥%d≠”node * int count=0; °Cn", Count(h)); * while(h!=NULL){ * * * * break; * * count += 1; * * * case 5: * * h = h->next; * * * * h = Reverse(h); * } * * * * break; * return count; * * * case 6: } * * * * printf("h1°G"); * * * * print_list(h1); node *Reverse(node *h){
  • 45. /*¶®•§jæ«∏Í∞T§uµ{æ«®t98Ø≈§AØZ≤¶•…¨u æ«∏π°GF74942294*/ * * * * printf("•H%dß@¨∞∞_¬I™∫Linked list°G", * return h; data); } / * * * * print_list(h1); ****************************************************************************** * * * * h1 = NULL; node *Search(int data, node *h){ * * * * * break; * node *p=h; FileName: hw7_s.c * * * case 4: * while(p!=NULL && data!=p->data)* p = p->next; Programmer: CrBoy * * * * printf("•ÿ´e™∫Linked list¶@¶≥%d≠”node * return p; Purpose: ≥–≥y§@≠”singly linked list®√∞ı¶Ê¶U∫ÿ•Ø‡ °Cn", Count(h)); } Input: * * * * break; Output: the standard out * * * case 5: int Count(node *h){ Compilation: gcc hw7_s.c -o hw7_s * * * * h = Reverse(h); * int count=0; Run: ./hw7_s * * * * break; * while(h!=NULL){ Date: 2006/1/8 * * * case 6: * * count += 1; / * * * * printf("h1°G"); * * h = h->next; ****************************************************************************** * * * * print_list(h1); * } / * * * * printf("h2°G"); * return count; * * * * print_list(h2); } #include <stdio.h> * * * * h = Merge(h1, h2); * * * * h1 = h2 = NULL; node *Reverse(node *h){ struct node{ * * * * break; * node *a, *b, *c; * int data; * * * case 7: * if(h==NULL || h->next==NULL) return h; * struct node *next; * * * * if(order) Split(&h, &h1, &h2); * a = h; }; * * * * else{ * b = a->next; * * * * * h = Reverse(h); * c = b->next; typedef struct node node; * * * * * Split(&h, &h1, &h2); * a->next = NULL; 新增! * * * * } * while(c!=NULL){ void print_list(node*);/*print_list(h); ¶C¶L•Hh∂}¿Y™∫linked list*/ * * * * printf("h1°G"); * * b->next = a; node *Insert(int, node*);/*Insert(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥ * * * * print_list(h1); * * a = b; °§Jdata®√¶^∂«∑s™∫h*/ * * * * printf("h2°G"); * * b = c; node *Delete(int, node*);/*Delete(data, h); ¶b•Hh∂}¿Y™∫linked list§§ßR∞ * * * * print_list(h2); * * c = c->next; £data®√¶^∂«∑s™∫h*/ * * * * break; * } node *Search(int, node*);/*Search(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥Mß * * * default: printf("±z™∫øȧJ¶≥ª~°In"); * b->next = a; ‰data®√∂«¶^data©“¶b™∫¶Ï∏m*/ * * * case 8: help(); * order = !order; 新增! int Count(node*);/*Count(h); ≠p∫‚•Hh∂}¿Y™∫linked list§§™∫∏`¬I≠”º∆*/ * * } * return b; node *Reverse(node*);/*Reverse(h); §œß«±∆¶C•Hh∂}¿Y™∫linked list®√∂«¶^∑s™∫h*/ * } } node *Merge(node*, node*);/*Merge(h1, h2); ¶X®÷h1ªPh2≥o2≠”linked ! temp = (node*)malloc(sizeof(node)); list®√¶^∂«¶X®÷´·™∫™∫head*/ ! temp->data = data; node *Merge(node *h1, node *h2){ void Split(node**, node**, node**);/*Split(&h, &h1, &h2); §¿≥Œh≥o≠”linked ! temp->next = p->next; * node *h, *temp; list¨∞©_∞∏º∆®√§¿ßO¶s®Ïh1ªPh2§§*/ ! p->next = temp; * h = temp = h1->data < h2->data ? h1 : h2; void help(); * return 0; * h1->data < h2->data ? (h1=h1->next) : (h2=h2->next); } * while(h1!=NULL && h2!=NULL){ int order=1; * * temp = temp->next = h1->data < h2->data ? h1 : h2; void print_list(node *h){ * * h1->data < h2->data ? (h1=h1->next) : (h2=h2->next); int main(void){ * node *temp; * } ! node *h1=NULL, *h2=NULL; * temp = h; * h2 == NULL ? (temp->next=h1) : (temp->next=h2); ! while(*h!=NULL){ * while(temp != NULL){ * return h; ! ! if((*h)->data%2){ * * printf("%d -> ", temp->data); } ! ! ! if(h1==NULL) h1 = *h1_ptr = *h; * * temp = temp->next; ! ! ! else *h1_ptr = (*h1_ptr)->next = *h; * } void Split(node **h, node **h1_ptr, node **h2_ptr){ ! ! }else{ * printf("NULLn"); * node *h1=NULL, *h2=NULL; ! ! ! if(h2==NULL) h2 = *h2_ptr = *h; } * while(*h!=NULL){ ! ! ! else *h2_ptr = (*h2_ptr)->next = *h; * * if((*h)->data%2){ ! ! } node *Insert(int data, node *h){ * * * if(h1==NULL) h1 = *h1_ptr = *h; ! ! *h = (*h)->next; * node *p, *t, *temp; * * * else *h1_ptr = (*h1_ptr)->next = *h; ! } * if(h==NULL){ * * }else{ ! (*h1_ptr)->next = (*h2_ptr)->next = NULL; * * temp = (node*)malloc(sizeof(node)); * * * if(h2==NULL) h2 = *h2_ptr = *h; ! *h1_ptr = h1; * * temp->data = data; * * * else *h2_ptr = (*h2_ptr)->next = *h; ! *h2_ptr = h2; * * temp->next = NULL; * * } ! *h = NULL; * * return temp; * * *h = (*h)->next; * int sel=8, data=0; * } * } * node *h=NULL, *h1=NULL, *h2=NULL; * p = h; * (*h1_ptr)->next = (*h2_ptr)->next = NULL; * help(); * t = h->next; * *h1_ptr = h1; * while(sel){ * if(data<p->data){ * *h2_ptr = h2; * * printf("n•ÿ´e™∫Linked list°G"); * * temp = (node*)malloc(sizeof(node)); * *h = NULL; * * print_list(h); * * temp->data = data; } * * printf("Ω–øÔ拕؇°G"); * * temp->next = p; * * if(scanf("%d", &sel)==0){ * * return temp; void help(){ * * * sel=-1; * } * printf("0.µ≤ßÙn"); * * * fflush(stdin); * if(t!=NULL) * printf("1.Insertn"); * * } * * while(data<p->data || data>t->data){ * printf("2.Deleten"); * * switch(sel){ * * * p = p->next; * printf("3.Searchn"); * * * case 0: break; * * * t = t->next; * printf("4.Countn"); * * * case 1: * * * if(t==NULL) break; * printf("5.Reversen"); * * * * printf("Ω–øȧJ±˝¥°§J™∫愺∆≠»°G"); * * } * printf("6.Mergen"); * * * * if(scanf("%d", &data)==0) continue; * temp = (node*)malloc(sizeof(node)); * printf("7.Splitn"); * * * * if(order) * temp->data = data; * printf("8.helpn"); * * * * * h = Insert(data, h); * temp->next = p->next; } * * * * else{ * p->next = temp; * * * * * h = Reverse(h); * return h; * * * * * h = Insert(data, h); } * * * * * h = Reverse(h); * * * * } node *Delete(int data, node *h){ * * * * break; * node *p, *t; * * * case 2: * if(h==NULL) return h; * * * * printf("Ω–øȧJ±˝ßR∞£™∫愺∆≠»°G"); * p = h; * * * * if(scanf("%d", &data)==0) continue; * t = h->next; * * * * if(order) * if(data == p->data){ * * * * * h = Delete(data, h); * * p = p->next; * * * * else{ * * free(h); * * * * * h = Reverse(h); * * return p; * * * * * h = Delete(data, h); * } * * * * * h = Reverse(h); * while(data!=t->data){ * * * * } * * p = p->next; * * * * break; * * t = t->next; * * * case 3: * * if(t==NULL) return h; * * * * printf("Ω–øȧJ±˝∑j¥M™∫愺∆≠»°G"); * } * * * * if(scanf("%d", &data)==0) continue; * p->next = t->next; * * * * h1 = Search(data, h); * free(t);
  • 46. /*¶®•§jæ«∏Í∞T§uµ{æ«®t98Ø≈§AØZ≤¶•…¨u æ«∏π°GF74942294*/ * * * * printf("•H%dß@¨∞∞_¬I™∫Linked list°G", * return h; data); } / * * * * print_list(h1); ****************************************************************************** * * * * h1 = NULL; node *Search(int data, node *h){ * * * * * break; * node *p=h; FileName: hw7_s.c * * * case 4: * while(p!=NULL && data!=p->data)* p = p->next; Programmer: CrBoy * * * * printf("•ÿ´e™∫Linked list¶@¶≥%d≠”node * return p; Purpose: ≥–≥y§@≠”singly linked list®√∞ı¶Ê¶U∫ÿ•Ø‡ °Cn", Count(h)); } Input: * * * * break; Output: the standard out * * * case 5: int Count(node *h){ Compilation: gcc hw7_s.c -o hw7_s * * * * h = Reverse(h); * int count=0; Run: ./hw7_s * * * * break; * while(h!=NULL){ Date: 2006/1/8 * * * case 6: * * count += 1; / * * * * printf("h1°G"); * * h = h->next; ****************************************************************************** * * * * print_list(h1); * } 刪除! / * * * * printf("h2°G"); * return count; * * * * print_list(h2); } #include <stdio.h> * * * * h = Merge(h1, h2); * * * * h1 = h2 = NULL; node *Reverse(node *h){ struct node{ * * * * break; * node *a, *b, *c; * int data; * * * case 7: * if(h==NULL || h->next==NULL) return h; * struct node *next; * * * * if(order) Split(&h, &h1, &h2); * a = h; }; * * * * else{ * b = a->next; * * * * * h = Reverse(h); * c = b->next; typedef struct node node; * * * * * Split(&h, &h1, &h2); * a->next = NULL; * * * * } ! while(c!=NULL){ void print_list(node*);/*print_list(h); ¶C¶L•Hh∂}¿Y™∫linked list*/ * * * * printf("h1°G"); ! ! b->next = a; node *Insert(int, node*);/*Insert(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥ * * * * print_list(h1); ! ! a = b; °§Jdata®√¶^∂«∑s™∫h*/ * * * * printf("h2°G"); ! ! b = c; node *Delete(int, node*);/*Delete(data, h); ¶b•Hh∂}¿Y™∫linked list§§ßR∞ * * * * print_list(h2); ! ! c = c->next; £data®√¶^∂«∑s™∫h*/ * * * * break; ! } node *Search(int, node*);/*Search(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥Mß * * * default: printf("±z™∫øȧJ¶≥ª~°In"); * b->next = a; ‰data®√∂«¶^data©“¶b™∫¶Ï∏m*/ * * * case 8: help(); * order = !order; int Count(node*);/*Count(h); ≠p∫‚•Hh∂}¿Y™∫linked list§§™∫∏`¬I≠”º∆*/ * * } * return b; node *Reverse(node*);/*Reverse(h); §œß«±∆¶C•Hh∂}¿Y™∫linked list®√∂«¶^∑s™∫h*/ * } } node *Merge(node*, node*);/*Merge(h1, h2); ¶X®÷h1ªPh2≥o2≠”linked ! temp = (node*)malloc(sizeof(node)); list®√¶^∂«¶X®÷´·™∫™∫head*/ ! temp->data = data; node *Merge(node *h1, node *h2){ void Split(node**, node**, node**);/*Split(&h, &h1, &h2); §¿≥Œh≥o≠”linked ! temp->next = p->next; * node *h, *temp; list¨∞©_∞∏º∆®√§¿ßO¶s®Ïh1ªPh2§§*/ ! p->next = temp; * h = temp = h1->data < h2->data ? h1 : h2; void help(); * return 0; * h1->data < h2->data ? (h1=h1->next) : (h2=h2->next); } * while(h1!=NULL && h2!=NULL){ int order=1; * * temp = temp->next = h1->data < h2->data ? h1 : h2; void print_list(node *h){ * * h1->data < h2->data ? (h1=h1->next) : (h2=h2->next); int main(void){ * node *temp; * } ! node *h1=NULL, *h2=NULL; * temp = h; ! while(c!=NULL){ ! while(*h!=NULL){ * while(temp != NULL){ ! ! b->next = a; ! ! if((*h)->data%2){ * * printf("%d -> ", temp->data); ! ! a = b; ! ! ! if(h1==NULL) h1 = *h1_ptr = *h; * * temp = temp->next; ! ! b = c; ! ! ! else *h1_ptr = (*h1_ptr)->next = *h; * } ! ! c = c->next; ! ! }else{ * printf("NULLn"); ! } ! ! ! if(h2==NULL) h2 = *h2_ptr = *h; } * h2 == NULL ? (temp->next=h1) : (temp->next=h2); ! ! ! else *h2_ptr = (*h2_ptr)->next = *h; * return h; ! ! } node *Insert(int data, node *h){ } 新增! ! ! *h = (*h)->next; * node *p, *t, *temp; ! } * if(h==NULL){ void Split(node **h, node **h1_ptr, node **h2_ptr){ ! (*h1_ptr)->next = (*h2_ptr)->next = NULL; * * temp = (node*)malloc(sizeof(node)); * node *h1=NULL, *h2=NULL; ! *h1_ptr = h1; * * temp->data = data; * while(*h!=NULL){ ! *h2_ptr = h2; * * temp->next = NULL; * * if((*h)->data%2){ ! *h = NULL; * * return temp; * * * if(h1==NULL) h1 = *h1_ptr = *h; * int sel=8, data=0; * } * * * else *h1_ptr = (*h1_ptr)->next = *h; * node *h=NULL, *h1=NULL, *h2=NULL; * p = h; * * }else{ * help(); * t = h->next; * * * if(h2==NULL) h2 = *h2_ptr = *h; * while(sel){ * if(data<p->data){ * * * else *h2_ptr = (*h2_ptr)->next = *h; * * printf("n•ÿ´e™∫Linked list°G"); * * temp = (node*)malloc(sizeof(node)); * * } * * print_list(h); * * temp->data = data; * * *h = (*h)->next; * * printf("Ω–øÔ拕؇°G"); * * temp->next = p; * } * * if(scanf("%d", &sel)==0){ * * return temp; * (*h1_ptr)->next = (*h2_ptr)->next = NULL; * * * sel=-1; * } * *h1_ptr = h1; * * * fflush(stdin); * if(t!=NULL) * *h2_ptr = h2; * * } * * while(data<p->data || data>t->data){ * *h = NULL; * * switch(sel){ * * * p = p->next; } * * * case 0: break; * * * t = t->next; * * * case 1: * * * if(t==NULL) break; void help(){ * * * * printf("Ω–øȧJ±˝¥°§J™∫愺∆≠»°G"); * * } * printf("0.µ≤ßÙn"); * * * * if(scanf("%d", &data)==0) continue; * temp = (node*)malloc(sizeof(node)); * printf("1.Insertn"); * * * * if(order) * temp->data = data; * printf("2.Deleten"); * * * * * h = Insert(data, h); * temp->next = p->next; * printf("3.Searchn"); * * * * else{ * p->next = temp; * printf("4.Countn"); * * * * * h = Reverse(h); * return h; * printf("5.Reversen"); * * * * * h = Insert(data, h); } * printf("6.Mergen"); * * * * * h = Reverse(h); * printf("7.Splitn"); * * * * } node *Delete(int data, node *h){ * printf("8.helpn"); * * * * break; * node *p, *t; } * * * case 2: * if(h==NULL) return h; * * * * printf("Ω–øȧJ±˝ßR∞£™∫愺∆≠»°G"); * p = h; * * * * if(scanf("%d", &data)==0) continue; * t = h->next; * * * * if(order) * if(data == p->data){ * * * * * h = Delete(data, h); * * p = p->next; * * * * else{ * * free(h); * * * * * h = Reverse(h); * * return p; * * * * * h = Delete(data, h); * } * * * * * h = Reverse(h); * while(data!=t->data){ * * * * } * * p = p->next; * * * * break; * * t = t->next; * * * case 3: * * if(t==NULL) return h; * * * * printf("Ω–øȧJ±˝∑j¥M™∫愺∆≠»°G"); * } * * * * if(scanf("%d", &data)==0) continue; * p->next = t->next; * * * * h1 = Search(data, h); * free(t);
  • 47. /*¶®•§jæ«∏Í∞T§uµ{æ«®t98Ø≈§AØZ≤¶•…¨u æ«∏π°GF74942294*/ * * * * printf("•H%dß@¨∞∞_¬I™∫Linked list°G", * * p = p->next; data); * * t = t->next; / * * * * print_list(h1); * * if(t==NULL) return h; ****************************************************************************** * * * * h1 = NULL; * } * * * * * break; * p->next = t->next; FileName: hw7_s.c * * * case 4: * free(t); Programmer: CrBoy * * * * printf("•ÿ´e™∫Linked list¶@¶≥%d≠”node * return h; Purpose: ≥–≥y§@≠”singly linked list®√∞ı¶Ê¶U∫ÿ•Ø‡ °Cn", Count(h)); } Input: * * * * break; Output: the standard out * * * case 5: node *Search(int data, node *h){ 刪除! Compilation: gcc hw7_s.c -o hw7_s * * * * h = Reverse(h); ! node *p=h; Run: ./hw7_s * * * * break; ! while(p!=NULL && data!=p->data)! p = p->next; Date: 2006/1/8 * * * case 6: ! return p; / * * * * printf("h1°G"); } ****************************************************************************** * * * * print_list(h1); / * * * * printf("h2°G"); int Count(node *h){ * * * * print_list(h2); ! int count=0; #include <stdio.h> * * * * h = Merge(h1, h2); ! while(h!=NULL){ * * * * h1 = h2 = NULL; ! ! count += 1; struct node{ * * * * break; ! ! h = h->next; * int data; * * * case 7: ! } * struct node *next; * * * * if(order) Split(&h, &h1, &h2); ! return count; }; * * * * else{ } * * * * * h = Reverse(h); typedef struct node node; * * * * * Split(&h, &h1, &h2); node *Reverse(node *h){ * * * * } * node *a, *b, *c; void print_list(node*);/*print_list(h); ¶C¶L•Hh∂}¿Y™∫linked list*/ * * * * printf("h1°G"); * if(h==NULL || h->next==NULL) return h; node *Insert(int, node*);/*Insert(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥ * * * * print_list(h1); * a = h; °§Jdata®√¶^∂«∑s™∫h*/ * * * * printf("h2°G"); * b = a->next; node *Delete(int, node*);/*Delete(data, h); ¶b•Hh∂}¿Y™∫linked list§§ßR∞ * * * * print_list(h2); * c = b->next; £data®√¶^∂«∑s™∫h*/ * * * * break; * a->next = NULL; node *Search(int, node*);/*Search(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥Mß * * * default: printf("±z™∫øȧJ¶≥ª~°In"); ! while(c!=NULL){ ‰data®√∂«¶^data©“¶b™∫¶Ï∏m*/ * * * case 8: help(); ! ! b->next = a; int Count(node*);/*Count(h); ≠p∫‚•Hh∂}¿Y™∫linked list§§™∫∏`¬I≠”º∆*/ * * } ! ! a = b; node *Reverse(node*);/*Reverse(h); §œß«±∆¶C•Hh∂}¿Y™∫linked list®√∂«¶^∑s™∫h*/ * } ! ! b = c; node *Merge(node*, node*);/*Merge(h1, h2); ¶X®÷h1ªPh2≥o2≠”linked ! temp = (node*)malloc(sizeof(node)); ! ! c = c->next; list®√¶^∂«¶X®÷´·™∫™∫head*/ ! temp->data = data; ! } void Split(node**, node**, node**);/*Split(&h, &h1, &h2); §¿≥Œh≥o≠”linked ! temp->next = p->next; * b->next = a; list¨∞©_∞∏º∆®√§¿ßO¶s®Ïh1ªPh2§§*/ ! p->next = temp; * order = !order; void help(); * return 0; * return b; } } int order=1; void print_list(node *h){ node *Merge(node *h1, node *h2){ int main(void){ * node *temp; * node *h, *temp; ! node *h1=NULL, *h2=NULL; * temp = h; * h = temp = h1->data < h2->data ? h1 : h2; ! while(*h!=NULL){ * while(temp != NULL){ * h1->data < h2->data ? (h1=h1->next) : (h2=h2->next); ! ! if((*h)->data%2){ * * printf("%d -> ", temp->data); * while(h1!=NULL && h2!=NULL){ ! ! ! if(h1==NULL) h1 = *h1_ptr = *h; * * temp = temp->next; * * temp = temp->next = h1->data < h2->data ? h1 : h2; ! ! ! else *h1_ptr = (*h1_ptr)->next = *h; * } * * h1->data < h2->data ? (h1=h1->next) : (h2=h2->next); ! ! }else{ * printf("NULLn"); * } ! ! ! if(h2==NULL) h2 = *h2_ptr = *h; } ! while(c!=NULL){ ! ! ! else *h2_ptr = (*h2_ptr)->next = *h; ! ! b->next = a; ! ! } node *Insert(int data, node *h){ ! ! a = b; ! ! *h = (*h)->next; * node *p, *t, *temp; ! ! b = c; ! } * if(h==NULL){ ! ! c = c->next; ! (*h1_ptr)->next = (*h2_ptr)->next = NULL; * * temp = (node*)malloc(sizeof(node)); ! } ! *h1_ptr = h1; * * temp->data = data; * h2 == NULL ? (temp->next=h1) : (temp->next=h2); ! *h2_ptr = h2; * * temp->next = NULL; * return h; ! *h = NULL; * * return temp; } 刪除! * int sel=8, data=0; * } * node *h=NULL, *h1=NULL, *h2=NULL; * p = h; void Split(node **h, node **h1_ptr, node **h2_ptr){ * help(); ! (*h1_ptr)->next = (*h2_ptr)->next = NULL; * node *h1=NULL, *h2=NULL; * while(sel){ ! *h1_ptr = h1; * while(*h!=NULL){ * * printf("n•ÿ´e™∫Linked list°G"); ! *h2_ptr = h2; * * if((*h)->data%2){ * * print_list(h); ! *h = NULL; * * * if(h1==NULL) h1 = *h1_ptr = *h; * * printf("Ω–øÔ拕؇°G"); * t = h->next; * * * else *h1_ptr = (*h1_ptr)->next = *h; * * if(scanf("%d", &sel)==0){ * if(data<p->data){ * * }else{ * * * sel=-1; * * temp = (node*)malloc(sizeof(node)); * * * if(h2==NULL) h2 = *h2_ptr = *h; 新增! * * * fflush(stdin); * * temp->data = data; * * * else *h2_ptr = (*h2_ptr)->next = *h; * * } * * temp->next = p; * * } * * switch(sel){ * * return temp; * * *h = (*h)->next; * * * case 0: break; * } * } ! ! ! case 1: * if(t!=NULL) * (*h1_ptr)->next = (*h2_ptr)->next = NULL; ! ! ! ! printf("Ω–øȧJ±˝¥°§J™∫愺∆≠»°G"); * * while(data<p->data || data>t->data){ * *h1_ptr = h1; ! ! ! ! if(scanf("%d", &data)==0) continue; * * * p = p->next; * *h2_ptr = h2; ! ! ! ! if(order) * * * t = t->next; * *h = NULL; ! ! ! ! ! h = Insert(data, h); * * * if(t==NULL) break; } ! ! ! ! else{ * * } ! ! ! ! ! h = Reverse(h); * temp = (node*)malloc(sizeof(node)); void help(){ ! ! ! ! ! h = Insert(data, h); * temp->data = data; * printf("0.µ≤ßÙn"); ! ! ! ! ! h = Reverse(h); * temp->next = p->next; * printf("1.Insertn"); ! ! ! ! } * p->next = temp; * printf("2.Deleten"); ! ! ! ! break; ! node *h=NULL, *h1=NULL, *h2=NULL; * printf("3.Searchn"); ! ! ! case 2: ! help(); * printf("4.Countn"); ! ! ! ! printf("Ω–øȧJ±˝ßR∞£™∫愺∆≠»°G"); * return h; * printf("5.Reversen"); ! ! ! ! if(scanf("%d", &data)==0) continue; } * printf("6.Mergen"); ! ! ! ! if(order) * printf("7.Splitn"); ! ! ! ! ! h = Delete(data, h); node *Delete(int data, node *h){ * printf("8.helpn"); ! ! ! ! else{ * node *p, *t; } ! ! ! ! ! h = Reverse(h); * if(h==NULL) return h; ! ! ! ! ! h = Delete(data, h); * p = h; ! ! ! ! ! h = Reverse(h); * t = h->next; ! ! ! ! } * if(data == p->data){ ! ! ! ! break; * * p = p->next; * * * case 3: * * free(h); * * * * printf("Ω–øȧJ±˝∑j¥M™∫愺∆≠»°G"); * * return p; * * * * if(scanf("%d", &data)==0) continue; * } * * * * h1 = Search(data, h); * while(data!=t->data){
  • 48. /*¶®•§jæ«∏Í∞T§uµ{æ«®t98Ø≈§AØZ≤¶•…¨u æ«∏π°GF74942294*/ * * * * printf("•H%dß@¨∞∞_¬I™∫Linked list°G", * * p = p->next; data); * * t = t->next; / * * * * print_list(h1); * * if(t==NULL) return h; ****************************************************************************** * * * * h1 = NULL; * } * * * * * break; * p->next = t->next; FileName: hw7_s.c * * * case 4: * free(t); Programmer: CrBoy * * * * printf("•ÿ´e™∫Linked list¶@¶≥%d≠”node * return h; Purpose: ≥–≥y§@≠”singly linked list®√∞ı¶Ê¶U∫ÿ•Ø‡ °Cn", Count(h)); } Input: * * * * break; Output: the standard out * * * case 5: node *Search(int data, node *h){ Compilation: gcc hw7_s.c -o hw7_s * * * * h = Reverse(h); ! node *p=h; Run: ./hw7_s * * * * break; ! while(p!=NULL && data!=p->data)! p = p->next; Date: 2006/1/8 * * * case 6: ! return p; / * * * * printf("h1°G"); } ****************************************************************************** * * * * print_list(h1); / * * * * printf("h2°G"); int Count(node *h){ * * * * print_list(h2); ! int count=0; #include <stdio.h> * * * * h = Merge(h1, h2); ! while(h!=NULL){ * * * * h1 = h2 = NULL; ! ! count += 1; struct node{ * * * * break; ! ! h = h->next; * int data; * * * case 7: ! } * struct node *next; * * * * if(order) Split(&h, &h1, &h2); ! return count; }; * * * * else{ } * * * * * h = Reverse(h); typedef struct node node; * * * * * Split(&h, &h1, &h2); node *Reverse(node *h){ * * * * } * node *a, *b, *c; void print_list(node*);/*print_list(h); ¶C¶L•Hh∂}¿Y™∫linked list*/ * * * * printf("h1°G"); * if(h==NULL || h->next==NULL) return h; node *Insert(int, node*);/*Insert(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥ * * * * print_list(h1); * a = h; °§Jdata®√¶^∂«∑s™∫h*/ * * * * printf("h2°G"); * b = a->next; node *Delete(int, node*);/*Delete(data, h); ¶b•Hh∂}¿Y™∫linked list§§ßR∞ * * * * print_list(h2); * c = b->next; 刪除! £data®√¶^∂«∑s™∫h*/ * * * * break; * a->next = NULL; node *Search(int, node*);/*Search(data, h); ¶b•Hh∂}¿Y™∫linked list§§¥Mß * * * default: printf("±z™∫øȧJ¶≥ª~°In"); ! while(c!=NULL){ ‰data®√∂«¶^data©“¶b™∫¶Ï∏m*/ * * * case 8: help(); ! ! b->next = a; int Count(node*);/*Count(h); ≠p∫‚•Hh∂}¿Y™∫linked list§§™∫∏`¬I≠”º∆*/ * * } ! ! a = b; node *Reverse(node*);/*Reverse(h); §œß«±∆¶C•Hh∂}¿Y™∫linked list®√∂«¶^∑s™∫h*/ * } ! ! b = c; node *Merge(node*, node*);/*Merge(h1, h2); ¶X®÷h1ªPh2≥o2≠”linked ! temp = (node*)malloc(sizeof(node)); ! ! c = c->next; list®√¶^∂«¶X®÷´·™∫™∫head*/ ! temp->data = data; ! } void Split(node**, node**, node**);/*Split(&h, &h1, &h2); §¿≥Œh≥o≠”linked ! temp->next = p->next; * b->next = a; list¨∞©_∞∏º∆®√§¿ßO¶s®Ïh1ªPh2§§*/ ! p->next = temp; * order = !order; void help(); * return 0; * return b; } } int order=1; void print_list(node *h){ node *Merge(node *h1, node *h2){ int main(void){ * node *temp; * node *h, *temp; ! node *h1=NULL, *h2=NULL; * temp = h; * h = temp = h1->data < h2->data ? h1 : h2; ! while(*h!=NULL){ * while(temp != NULL){ * h1->data < h2->data ? (h1=h1->next) : (h2=h2->next); ! ! if((*h)->data%2){ * * printf("%d -> ", temp->data); * while(h1!=NULL && h2!=NULL){ ! ! ! if(h1==NULL) h1 = *h1_ptr = *h; * * temp = temp->next; * * temp = temp->next = h1->data < h2->data ? h1 : h2; ! ! ! else *h1_ptr = (*h1_ptr)->next = *h; * } * * h1->data < h2->data ? (h1=h1->next) : (h2=h2->next); ! ! }else{ * printf("NULLn"); * } ! ! ! if(h2==NULL) h2 = *h2_ptr = *h; } ! while(c!=NULL){ ! ! ! else *h2_ptr = (*h2_ptr)->next = *h; ! ! b->next = a; ! ! } node *Insert(int data, node *h){ ! ! a = b; ! ! *h = (*h)->next; * node *p, *t, *temp; ! ! b = c; ! } * if(h==NULL){ ! ! c = c->next; ! (*h1_ptr)->next = (*h2_ptr)->next = NULL; * * temp = (node*)malloc(sizeof(node)); ! } ! *h1_ptr = h1; * * temp->data = data; * h2 == NULL ? (temp->next=h1) : (temp->next=h2); ! *h2_ptr = h2; * * temp->next = NULL; * return h; ! *h = NULL; * * return temp; } * int sel=8, data=0; * } * node *h=NULL, *h1=NULL, *h2=NULL; * p = h; void Split(node **h, node **h1_ptr, node **h2_ptr){ * help(); ! (*h1_ptr)->next = (*h2_ptr)->next = NULL; * node *h1=NULL, *h2=NULL; * while(sel){ ! *h1_ptr = h1; * while(*h!=NULL){ * * printf("n•ÿ´e™∫Linked list°G"); ! *h2_ptr = h2; * * if((*h)->data%2){ * * print_list(h); ! *h = NULL; * * * if(h1==NULL) h1 = *h1_ptr = *h; * * printf("Ω–øÔ拕؇°G"); * t = h->next; * * * else *h1_ptr = (*h1_ptr)->next = *h; * * if(scanf("%d", &sel)==0){ * if(data<p->data){ * * }else{ 新增! * * * sel=-1; * * temp = (node*)malloc(sizeof(node)); * * * if(h2==NULL) h2 = *h2_ptr = *h; * * * fflush(stdin); * * temp->data = data; * * * else *h2_ptr = (*h2_ptr)->next = *h; * * } * * temp->next = p; * * } * * switch(sel){ * * return temp; * * *h = (*h)->next; * * * case 0: break; * } * } ! ! ! case 1: * if(t!=NULL) * (*h1_ptr)->next = (*h2_ptr)->next = NULL; ! ! ! ! printf("Ω–øȧJ±˝¥°§J™∫愺∆≠»°G"); * * while(data<p->data || data>t->data){ * *h1_ptr = h1; ! ! ! ! if(scanf("%d", &data)==0) continue; * * * p = p->next; * *h2_ptr = h2; ! ! ! ! if(order) * * * t = t->next; * *h = NULL; ! ! ! ! ! h = Insert(data, h); * * * if(t==NULL) break; } ! ! ! ! else{ * * } ! ! ! ! ! h = Reverse(h); * temp = (node*)malloc(sizeof(node)); void print_list(node *h){ ! ! ! ! ! h = Insert(data, h); * temp->data = data; ! node *temp; ! ! ! ! ! h = Reverse(h); * temp->next = p->next; ! temp = h; ! ! ! ! } * p->next = temp; ! while(temp != NULL){ ! ! ! ! break; ! node *h=NULL, *h1=NULL, *h2=NULL; ! ! printf("%d -> ", temp->data); ! ! ! case 2: ! help(); ! ! temp = temp->next; ! ! ! ! printf("Ω–øȧJ±˝ßR∞£™∫愺∆≠»°G"); * return h; ! } ! ! ! ! if(scanf("%d", &data)==0) continue; } ! printf("NULLn"); ! ! ! ! if(order) } ! ! ! ! ! h = Delete(data, h); node *Delete(int data, node *h){ ! ! ! ! else{ * node *p, *t; void help(){ ! ! ! ! ! h = Reverse(h); * if(h==NULL) return h; * printf("0.µ≤ßÙn"); ! ! ! ! ! h = Delete(data, h); * p = h; * printf("1.Insertn"); ! ! ! ! ! h = Reverse(h); * t = h->next; * printf("2.Deleten"); ! ! ! ! } * if(data == p->data){ * printf("3.Searchn"); ! ! ! ! break; * * p = p->next; * printf("4.Countn"); * * * case 3: * * free(h); * printf("5.Reversen"); * * * * printf("Ω–øȧJ±˝∑j¥M™∫愺∆≠»°G"); * * return p; * printf("6.Mergen"); * * * * if(scanf("%d", &data)==0) continue; * } * printf("7.Splitn"); * * * * h1 = Search(data, h); * while(data!=t->data){ * printf("8.helpn");