這是Herr Deng桑的教學blog,主要處理作業與班導事務,另外還有數位小品。
1. gcd(55,121)=11 5 55 121 2 55 110 0 115 115. (1)sizeof(x)=4+30+4=38→40 (2)輸出noname 507. (1)stuct Node int coef; int exp; struct Node*next;8. (2) i 0 1 2 3 4 k=(i+4)%5 4 0 1 2 3 array[k] 8 1 2 3 5 first→5→3→2→1→8→NULL (3) 5 3 2 19. (1)插入中間節點: newnode→next=ptr→next; ptr→next=newnode; (2)刪除中間節點 while(current→next!=ptr) current→next=ptr→next; current=ptr→next;
1.int gcd(int x,int y) {int r=x%y; if (r==0)return y; else return gcd(y,r); }算式: 5│55│121│2 │55│110│ ├─┼──┤ │ 0│ 11│ 5.(1) 4+30+4=38→40 (2) noname 507.(1) sturuct Node{ int coef; int exp; sturuct Node*next; }8.(1) struct Node{ int date; struct Node*next; } (2) First→5→3→2→1→8→NULL (3) 5 3 2 19.刪除中間節點 while(current→next!=ptr) current=current→next; cuttent→next=ptr→next;
1.int gcd ( int x , int y ){ int r = x % y ; if ( r = = 0 ) return y ; else return gcd ( y , r ) ;}gcd ( 55 , 121 ) = 115.(2)noname507.(1) struct Node { int coef ; int exp ; struct Node *next ;}8.(2) i 0 1 2 3 4k=(i+4)%5 4 0 1 2 3array[k] 8 1 2 3 5first->5->3->2->1->8->NULL8.(3)5321
題目2.(2)i=n; do{ a-=3; i/=3; }while(a>0); Ans: O(n)題目3. 記憶體 位置 名稱 型態 301 0x0012FF7C i int 50 0x0012FF78 j int0x0012FF78 0x0012FF74 ptr *int0x0012FF7C 0x0012FF70 ptr1 *int* ptr = 50 * ptr1 = 301題目7.(1)Node之定義:struct Node{ int coef; int exp; struct Node* next;};題目8.(2) i 0 1 2 3 4 k=(i+4)%len 4 0 1 2 3 array[k] 8 1 2 3 5 first→5→3→2→1→8→NULL(3)輸出5321
2. (2) 0(n)3. 記憶體 位置 名稱 型態 301 0x0012FF7C i int 50 0x0012FF78 j int0x0012FF78 0x0012FF74 ptr int*0x0012FF7C 0x0012FF70 ptr1 int* *ptr=50 ptr1=3015. (1)4+30+4=38→40 (2)noname 507. (1)struct Node{ int coef; int exp; struct Node*next; } (3)所有節點都是中間節點8.(1) struct Node{ int data; struct Node*next; } (2) 5 0 1 2 3 4 (i+4)%len 4 0 1 2 3 Array【k】 8 1 2 3 5 first→5 →3 →2 →1 →8 →NULL (3) 5 3 2 1
第一題int gcd(int x, int y){int r=x%y;if(r==0)return y;elsereturn gcd(y,r);}121/55=2...餘11 (121,11)121/11=11...餘0 (121,11)Ans 11第七題struct Node{int coef;int exp;struct Node*next;}第三題sizeof(int)=4(bytes)int i=301;int j-i/6;int*ptr=&j;int*ptr=&i;記憶體 位置 名稱 型態301 Ox0012FF7C i int50 Ox0012FF78 j int Ox0012FF78 Ox0012FF74 ptr int*Ox0012FF7C Ox0012FF70 ptr1 int**ptr=50 *ptr1=301第八題i 0 1 2 3 4(i+4)%len 4 0 1 2 3array[k] 8 1 2 3 5first→5→3→2→1→8→NULL輸出5321
1. int gcd(int x,int y);{ int r=x%y; if(r==0) return y; else return gcd(y,r); } gcd(55,121)=113. 記憶體 位置 名稱 型態301 0*0012FF7C i int50 0*0012FF78 j int0*0012FF78 0*0012FF74 ptr int* 0*0012FF7C 0*0012FF70 ptr1 int**ptr=50 *ptr=3015.(1)sizeof(x)=4+30+4=38→40(2)輸出 noname 507.(1) struct Node{ int coef; int exp; struct Node*next;}8.(1) struct*Node{ int data; struct Node*next;}(2) i 0 1 2 3 4k=(i+4)%5 4 0 1 2 3array[k] 8 1 2 3 5first→5→3→2→1→8→NULL(3)5321
1.int gcd (int x,y ){int r=x%y;if (r==0) return y;elsereturn ( y , r ) ;}5|55|121|2 |55|110| | 0| 11| 5.(1).40(2).noname 50 7.(1).struct node;{int coef;int exp;struct node*next;} 8.(2). i 0 1 2 3 4i+4%5 4 0 1 2 3array[k]8 1 2 3 5first→5→3→2→1→8→NULL(3).5321 (9).插入中間節點newnod->next=ptr->next;ptr->next=newnode; 刪除中間節點while(current->next!=ptr) current = current->next;currnet->next = ptr ->next;
1. int gcd (int x, int y) { int r=x%y if (r==0) return y; else return gcd (y,r); } gcd(55,121)=112. (2)O(n)3. 記憶體 位置 名稱 型態 301 0x0012FF7C i int 50 0x0012FF78 j int 0x0012FF78 0x0012FF74 ptr int* 0x0012FF7C 0x0012FF70 ptr1 int* *ptr=50 *ptr1=3015. (1)4+30+4=38→406. row col value 0 0 7 0 8 3 3 3 3 0 4 77. (1) struct Node{ int coef; int exp; struct Node *next; } (3) 所有節點都是中間節點。8. (2)first→5→3→2→1→8→NULL (3) 5 3 2 19. 插入中間節點 newnode=ptr→next; ptr→next=newnode; 刪除中間節點 while (current→next!=ptr) current→next=ptr→next; current=ptr→next;
1. int gcd (int x, int y) { int r = x%y; if return y; else return }2. i=n; do{ a-=3; i/=3; }while(a>0);On 3. 記憶體 位置 名稱 型態 301 0x0012FF7C i int 50 0x0012FF78 j int0x0012FF78 0x0012FF74 ptr *int0x0012FF7C 0x0012FF70 ptr1 *int* ptr = 50 * ptr1 = 3015. a. 4+30+4=38 b. noname 38+2=40 50 sizeof(x)=404. float d[9*12]; int n=9 , k=12 … for(i=0; i<n; i++) for(j=0; j<k; j++) d[i*k+j]=(float) fun(i)/fun(j);6. (1) struct Node{ int coef; int exp; struct Node*new } (3)因為所有節點都變成中間節點,變成只要處理中間節點8. (1) struct Node{ (2) i 0 1 2 3 4 (3) int data; k=(i+4)%5 4 0 1 2 3 5 struct Node*new; array[k] 8 1 2 3 5 3 } first->5->3->2->1->8->Null 2 1 9. while(current->next!=ptr) current = current->next; current->next = ptr->next;
3.記憶體 位置 名稱 型態 301 0x0012FF7C i int 50 0x0012FF78 j int0x0012FF78 0x0012FF74 ptr int*0x0012FF7C 0x0012FF70 ptr1 int**ptr=50 *ptr1=3015.(1)4+30+4=38→40(2)noname 50 sizeof(x)=407.(1)struct Node{ int coef; int exp; struct Node* next; }8.(1)struct Node{ int data; struct Node*next; } (2) i 0 1 2 3 4 k=(i+4)%5 4 0 1 2 3 array[k] 8 1 2 3 5 first→5→3→2→1→8→NULL (3) 5 3 2 19.插入中間節點: newnode→next=ptr→next; ptr→next=newnode; 刪除中間節點: While(current→next!=ptr) current=current→next; current→next=ptr→next;
1.int gcd (int x , int y){int r = x % y ;if(r = = 0) return y;else return gcd (y , r);}ANS: x y 55 121r=55 121 55r=11 55 11r=55y=112.i = n;do {a-=3;i/=3;}while (a>0);ANS:O(n)3.記憶體 位置 名稱 型態301 0*0012FF7C i int50 0*0012FF78 j int0*0012FF78 0*0012FF74 ptr int*0*0012FF7C 0*0012FF70 ptr1 int*ANS:*ptr=50 *ptr1=3015.(1)size of (x) = 4+30+4 = 38 → 40(2)noname 507.(1)struct Node {int coef;int exp;struct Node*next;}8.(2)i 0 1 2 3 4 k=(1+4%5) 4 0 1 2 3array 8 1 2 3 5first → 5 → 3 → 2 → 1 → 8 → NULL(3)5 3 2 1
5.(1)4+30+4=38因為要四的倍數所以等於407.(1) struct node { int coff; int exp; struct node *next };8.(2) first->5->3->2->1->8->NULL(3)5 3 2 1
題目1.----------------------------------int gcd (int x, int y){ int r = y % x ; if (r==0) return x; else retutn gcd(x,r);}計算2|121|55|5 |110|55| |---|--| | 11| 0| ----------------------------------題目2.(2)----------------------------------i=n;do{ a-=3; i/=3;}while (a>0);ANS:O(n)----------------------------------題目3.---------------------------------- 記憶體 、 位置 、 名稱、 型態 301、 0x0012FF7C 、 i 、int 50 、 0x0012FF78 、 j 、 int0x0012FF78 、0x0012FF74 、ptr 、 int*0x0012FF7C、 0x0012FF70 、 ptr1 、int*ptr=50 ptr1=301----------------------------------題目5.(1)----------------------------------4+30+4=38 → 40----------------------------------題目6.----------------------------------列 欄 值 0 0 7 0 8 3 3 3 3 4 0 7----------------------------------題目7.(1)----------------------------------struct Node{ int coef; int exp;struct Node* next;}----------------------------------題目8.---------------------------------- i : 0 、 1 、2、 3 、 4(i+4)%5 : 4、 0 、 1 、 2 、 3array[k]: 8 、1 、 2 、3 、5(2) first → 5 → 3 → 2 → 1 → 8 → NULL(3) 5321----------------------------------
1. gcd(55,121)=115 55 121 255 1100 115112.0(nlogn) 0(n)3.50 0x0012FF780x0012FF78 0x0012FF740x0012FF7C 0x0012FF70*ptr=50 *ptr1=3015.(1)sizeof(x)=4+30+4=38→40(2)輸出noname506.row 0034col 0830vol 73377. (1)stuct Nodeint coef;int exp;struct Node*next;8.(1)struct Node{int data;struct Node*next;}(2)i 01234k=(i=4)%5 40123array[k] 81235first→5→3→2→1→8→NULL(3)53219.(1)插入中間節點:newnode→next=ptr→next;ptr→next=newnode;(2)刪除中間節點while(current→next!=ptr)current→next=ptr→next;current=ptr→next;
1.gcd(55,121)=115︳55︳121︳2 ︳55︳110︳ ︳ 0︳ 11︳2. (2.)i=n;do{a-=3;i/=3;while(a>0);Big O=O(n)3.sizeof(int)=4(bytes)int i=301;int j-i/6;int*ptr=&j;int*ptr=&i;記憶體 位置 名稱 型態 301 |0x0012FF7C| i int 50 |0x0012FF78| j int0x0012FF78| 0x0012FF74| ptr int*0x0012FF7C| 0x0012FF70| ptr1 int*5.(1)sizeof(x)=4+30+4=38→408.(2)i → 0 1 2 3 4k=(i+4)%5→ 4 0 1 2 3array[k] → 8 1 2 3 5first→5→3→2→1→8→NULL(3)5321
5.(1)4+30+4=38-佔40個位元8.(2) i:0 1 2 3 4k=(i+4)%5:4 0 1 2 3 array[k]:8 1 2 3 5first→5→3→2→1→8→Null(3)5321
1.int gcd(intx, inty) { int r=x%y; if(r==0)return y; else return gcd(y,r); } gcd(55,121)=112.0(nlogn) 0(n) 0(logn)3. 301 0x0012FF7C i int 50 0x0012FF78 j int 0x0012FF78 0x0012FF74 ptr int* 0x0012FF7C 0x0012FF70 ptr int* *prt = 50 *ptr1 = 3015. 4+30+4 =38 sizeof(X)=40 noname 507. struct Node { int coef; int exp; struct Node*next; }8. i 0 1 2 3 4 k=(i+4)%5 4 0 1 2 3 array[k] 8 1 2 3 5 first-5-3-2-1-8-NULL 5 3 2 19. 刪除中間節點 while(current->next!=ptr) current=current->next; current->next=ptr->next; 插入中間節點 newnode->next=ptr->next; ptr->next=newnode;
1. gcd(55,121)=115 55 121 255 1100 115112.(2)O(n)3. 301 0x0012ff7c 50 0x0012ff780x0012ff78 0x0012ff740x0012ff7c 0x0012ff70*ptr=50 *ptr1=3014.float[9*12]; c[i*k+j]=(float)fun(i)/fun(j);5. (1)sizeof(x)=4+30+4=38→40(2)輸出noname507. (1)stuct Nodeint coef;int exp;struct Node*next;8. (2) i 0 1 2 3 4k=(i+4)%5 4 0 1 2 3array[k] 8 1 2 3 5first→5→3→2→1→8→NULL(3) 53219. (1)插入中間節點:newnode→next=ptr→next;ptr→next=newnode;(2)刪除中間節點while(current→next!=ptr)current→next=ptr→next;current=ptr→next;
1.gcd(55,121)=115 55 121 2 55 110 0 112.(1)O(n longn)5.(2)輸出=noname 507.(1)struct Node{ int coef; int exp; struct Node*next; }(3)所有節點都是中間節點8.(2) i 0 1 2 3 4k=(i+4)%5 4 0 1 2 3 array[k] 8 1 2 3 5first→5→3→2→1→8→Null(3)5321
1.gcd(55,121)=115│55│121│2.│55│110│.│ 0│ 11│int gcd(int x,int y){int r=x%y;if(r==0)x%y;if(r==0)returny;else retum grd(y,r);}2.(1)O( n log n )(2)O(n)5.(1)sizef(x)=4+30+4=38→40(2)輸出 noname507.(1)struct Node{int coef;int exp;struct Node* next;}(3)使用開頭節點的環狀串列之優點:所有節點都是中間節點。8.(1)struct Node{int data a;struct Node* next;}(2) i│0 1 2 3 4k=(i+4)%5│4 0 1 2 3array[k] │8 1 2 3 5 first→5→3→2→1→8→NULL(3)5 3219.插入中間節點:newnode→next=ptr→next;prt→next=newnode;刪除中間節點:while(current=current→next;current→next=prt→next;)
1. int gcd(int x,int y) { int r==x%y; if (r==0) return y; else return gcd(y,r); } 5|55|121|2 gcd(55,121)=11 |55|110| | 0| 11|3. 記憶體 位置 名稱 型態 301 | 0x0012FF7C | i int 50 | 0x0012FF78 | j int0x0012FF78 | 0x0012FF74 | ptr *int0x0012FF7C | 0x0012FF70 | ptr1 *int *ptr=50 *ptr1=3015. (1)4+30+4=38→40 (2)noname 507. struct Node{ int coef; int exp; struct Node*next; }8.(1) struct Node{ int data; struct Node*next; } (2) i | 0 1 2 3 4 k=(i+4)%5| 4 0 1 2 3 array[k] | 8 1 2 3 5 first→5→3→2→1→8→NULL (3)5 3 2 19. 刪除中間節點 while(current→next!=ptr) current=current→next; cuttent→next=ptr→next;
(1)struct Node{ int data; struct Node*next; }(2) i 0 1 2 3 4 k=(i+4)%5 4 0 1 2 3 array[k] 8 1 2 3 5 first→5→3→2→1→8→NULL(3) 5 3 2 1
8.(1)struct Node{ int data; struct Node*next; }(2) i 0 1 2 3 4 k=(i+4)%5 4 0 1 2 3 array[k] 8 1 2 3 5 first→5→3→2→1→8→NULL(3) 5 3 2 1
題目一 int gcd (int x,y ){int r=x%y;if (r==0) return y;elsereturn ( y , r ) ;}5|55|121|2|55|110|| 0| 11|題目三記憶體 位置 名稱 型態 301 0*0012FF7C i int 50 0*0012FF78 j int0*0012FF78 0*0012FF74 ptr int* 0*0012FF7C 0*0012FF70 ptr1 int**ptr=50 *ptr=301題目五(1)sizeof(x)=4+30+4=38→40(2)輸出noname50題目七(1) struct Node{int coef;int exp;struct Node *next;}(3) 所有節點都是中間節點題目八(2)first→5→3→2→1→8→NULL(3) 5321題目九插入中間節點newnode=ptr→next;ptr→next=newnode;刪除中間節點while (current→next!=ptr)current→next=ptr→next;current=ptr→next;
題目1.struct*gcd(int x,int y)}int r;r=(x%y);if(r==0) return yelse return gcd(y,r);{題目2.1.0(nlogn) 2.0(n) 3.0(logn)題目5.1. 4+30+4=38→402. noname 50題目7.sturuct Node{int coef;int exp;sturuct Node*next;}題目8.(1) struct Node{int data;struct Node*next;}(2)i 0 1 2 3 4(i+4)%len 4 0 1 2 3array[k] 8 1 2 3 5 first→5 →3 →2 →1 →8 →NULL(3) 5321
第一題int gcd(int x,int y){int r=x%y;if (r==0)return y;else return gcd(y,r);}第二題1) O(n log n) 2) O(n) 3) O(log n) 第五題(1)sizeof(x)=4+30+4=38→40(2)輸出noname50第七題sturuct Node{int coef;int exp;sturuct Node*next;}第八題1)struct*Node{int data;struct Node*next;}2)i 0 1 2 3 4(i+4)%len 4 0 1 2 3array[k] 8 1 2 3 5first→5→3→2→1→8→NULL輸出5321第九題源碼while(current→next!=ptr)current=current→next;cuttent→next=ptr→next;
1. gcd(55,121)=115 55 121 255 1100 11511(2)i=n;do{ a-=3;i/=3;}while(a>0);Ans: O(n)3. 記憶體 位置 名稱 型態301 0x0012FF7C i int50 0x0012FF78 j int0x0012FF78 0x0012FF74 ptr *int0x0012FF7C 0x0012FF70 ptr1 *int* ptr = 50 * ptr1 = 3018.i 0 1 2 3 4(i+4)%len 4 0 1 2 3array[k] 8 1 2 3 5first→5→3→2→1→8→NULL輸出53219.(1)插入中間節點:newnode→next=ptr→next;ptr→next=newnode;(2)刪除中間節點while(current→next!=ptr)current→next=ptr→next;current=ptr→next;
1. int gcd(intx,inty) { int r=x%y; if(r==0)return y; else return gcd(y,r); }2.(2) O(n)3. 記憶體 位置 名稱 型態 301 0x0012ff7c i int 50 0x0012ff78 j int 0x0012ff78 0x0012ff74 ptr int* 0x0012ff74 0x0012ff70 ptr1 int**ptr=50 *ptr1=3014. float d[108]; int n=9,k=12; for(i=0;i < n;i++) for(j=0;j < k;j++) d[i*l+j]=float fun(i)/fun(j);5. (1) sizeof(x)=4+30+4=38--->40 (2) noname 507. (1) struct Node { int coef; int exp; struct Node*next; (2) 所有節點都是中間節點8. (2) i 0 1 2 3 4k=(i+4)%5 4 0 1 2 3array[k] 8 1 2 3 5 first->5->3->2->1->8->NULL (3) 5 3 2 19. 插入: next->next=ptr->next; Newnode=ptr->next; 刪除: while(current->next!=ptr) current=current->next; current->next=ptr->next;
1. int gcd(intx,inty) { int r=x%y; if(r==0)return y; else return gcd(y,r); }2.(2) O(n)3. 記憶體 位置 名稱 型態 301 0x0012ff7c i int 50 0x0012ff78 j int 0x0012ff78 0x0012ff74 ptr int* 0x0012ff74 0x0012ff70 ptr1 int**ptr=50 *ptr1=3014. float d[108]; int n=9,k=12; for(i=0;i < n;i++) for(j=0;j < k;j++) d[i*l+j]=float fun(i)/fun(j);5. (1) sizeof(x)=4+30+4=38--->406. row col value 0 0 7 0 8 3 3 3 3 4 0 77. (1) struct Node { int coef; int exp; struct Node*next; (2) 所有節點都是中間節點8. (2) i 0 1 2 3 4k=(i+4)%5 4 0 1 2 3array[k] 8 1 2 3 5 first->5->3->2->1->8->NULL (3) 5 3 2 19. 插入: next->next=ptr->next; Newnode=ptr->next; 刪除: while(current->next!=ptr) current=current->next; current->next=ptr->next;
7(1)Node之定義?struct Node{int coef;int exp;struct Node* next;}8(2)first-> 5-> 3-> 2-> 1-> 8-> NULL(3)5321
1.int gcd(int x,int y){int r=x%y;if (r==0)return y;else return gcd(y,r);}2.(1)o(nlogn) (2) o(n) (3) o(logn) 3. 記憶體 位置 名稱 型態301 0x0012FF7C i int50 0x0012FF78 j int0x0012FF78 0x0012FF74 ptr *int0x0012FF7C 0x0012FF70 ptr1 *int* ptr = 50 * ptr1 = 3014.float d[108];int n=9 、k=12…for(i=0; i<n; i++)for(j=0; j<k; j++)d[i*k+j]=(float) fun(i)/fun(j);5.1)sizeof(x)=4+30+4=38→40(2)輸出noname507.(1) struct Node{int coef;int exp;struct Node *next;}(3) 所有節點都是中間節點。8.(2)first→5→3→2→1→8→NULL(3) 5.3.2.19.插入中間節點newnode=ptr→next;ptr→next=newnode;刪除中間節點while (current→next!=ptr)current→next=ptr→next;current=ptr→next;
1. int gcd (int x,int y){ int r=x%y; if (r= =o)return y; else return gcd (y,r);}2.(1)0(n logn)(2)0(n)(3)0(logn)3.記憶體 位置 名稱 型態30 0x0012FF7C i int 50 0x0012FF78 j int0x0012FF78 0x0012FF74 ptr int*0x0012FF74 0x0012FF70 ptr1 int*4.float[9*12]; c[i*k+j]=(float)fun(i)/fun(j);5.(2)noname 506.row col val 0 0 7 0 8 3 3 3 3 4 0 77.(1)struct Node{ int coef; int exp; struct Node*next; }8.(2) i 0 1 2 3 4 k=(i+4)%5 4 0 1 2 3array 8 1 2 3 5
1.int gcd (int x, int y) gcd(55,121)=11int r=x%y; if(r==0) return;else return gcd (y,r);5│55│121│2 │55│121│============= │0 │11│2.0(n logn) 0(n) 0(log n)5.(1)4+30+4=38-->40(2)noname 507.(1)stuct Node{int coef;int exp;struct Node*next;}(3)所有節點都是中間節點8.(2) i │ 01234k=(i+4)55│ 40123array[k] │ 81235 (3) 53219.插入中間節點newnod->next=ptr->next;ptr->next=newnode;
1.int gcd (int x, int y){int r=x%yif (r==0) return y;else return gcd (y,r);}gcd(55,121)=112.(1)o(n logn)(2)O(n)3.記憶體 位置 名稱 型態301 0x0012FF7C i int50 0x0012FF78 j int0x0012FF78 0x0012FF74 ptr *int0x0012FF7C 0x0012FF70 ptr1 *int* ptr = 50 * ptr1 = 3015.(1)sizeof(x)=4+30+4=38→40(2)輸出noname= 507.dtruct Node{int coef;int exp;struct Node*next;}8.(1)struct Node{int data;struct Node*next;}(2)i 0 1 2 3 4k=i+4%5 4 0 1 2 3array[k] 8 1 2 3 5first→5→3→2→1→8→NULL(3)53219.刪除中間節點while (current→next!=prt) current→next=ptr→next; current=ptr→next;
1. 5│55│121│2 │55│110│ ├─┼──┤ │ 0│ 11│ int gcd(int x,int y){int r=x%y;if (r==0)return y;else return gcd(y,r);}2-2 O(n)5-1 4+30+4=38→405-2 n0name 507-1 stuct Node int coef; int exp; struct Node*next;7-3 所有節點都是中間節點8-1 struct Node{int date;struct Node*next;}8-2first→5→3→2→1→8→NULL8-353219-2while(current→next!=ptr)current=current→next;cuttent→next=ptr→next;
1.int gcd(int x,int y){int r=x%y; if (r==0) return y; else return gcd(y,r);}5.(1)sizeof(x)=40(2)noname506.欄 列 值0 0 70 8 33 3 34 0 77.struct Node{int coef;int exp;struct Node*next;}8.(2) i 0 1 2 3 4k=(i+4)%5 4 0 1 2 3array[k] 8 1 2 3 5(3)53219.while(current->next!=ptr) current=current->next; current->next=ptr->next;
1.gcd( int x,int y ){r=x % y;if( r==0 )return y;elsereturn gcd ( y,r );5.(1)30+4+4=38 40-->要四倍數(2)noname 507.struct Node {int coef;int exp;struct Node* next;}8.(1)struct Node{int datastruct Node* next;};(2)frist->5->3->2->1->8->NULL(3)53219. 插入: next->next=ptr->next; Newnode=ptr->next; 刪除: while(current->next!=ptr) current=current->next; current->next=ptr->next;
1.int gcd(int x,int y){int r=x%y;if (r==0)return y;elsereturn gcd(y,r) ;}gcd (55,121) = 112. (1)O(nlogn) (2)O(n)(3)O(logn)5. sizeof(x)=4+30+4=38→407.(1) struct Node{ int coef; int exp; struct Node* next;}
1.int gcd(int x,int y);{int r=x%y;if(r==0)return y;elsereturn gcd(y,r);}gcd(55,121)=114. float d[9*12];int n=9 , k=12for(i=0; i<n; i++)for(j=0; j<k; j++)d[i*k+j]=(float) fun(i)/fun(j);5. (1)sizeof(x)=4+30+4=38→40 (2)輸出noname 507.(1) struct Node { int coef; int exp; struct Node*next; }8. (2)first→5→3→2→1→8→NULL(3) 5 3 2 19.刪除中間節點while (current→next!=ptr)current→next=ptr→next;current=ptr→next;
1.int gcd ( int x , int y ){int r = x % y ;if ( r = = 0 )return y ;elsereturn gcd ( y , r ) ;}gcd ( 55 , 121 ) = 115 55 121 255 1100 11511Ans:112.(2)i=n;do{ a-=3;i/=3;}while(a>0); Ans:O(n)3.記憶體 位置 名稱 型態301 0x0012FF7C i int50 0x0012FF78 j int0x0012FF78 0x0012FF74 ptr int*0x0012FF7C 0x0012FF70 ptr1 int**ptr=50 *ptr1=3015.(2)輸出 noname 507.(1)struct Node{int coef;int exp;struct Node*next;}8.(2) i 0 1 2 3 4k=(i+4)%5 4 0 1 2 3array[k]8 1 2 3 5first→5→3→2→1→8→NULL(3) 5 3 2 19.(1)插入中間節點:newnode→next=ptr→next;ptr→next=newnode;(2)刪除中間節點while(current→next!=ptr)current→next=ptr→next;current=ptr→next;
1.int gcd(int x,int y){int r=x%y;if (r==0)return y;else return gcd(y,r);}算式:5│55│121│2 │55│110│ │──┼───┤ │ 0│ 11│ 2.(1)o(n)*o(log n)=o(n(log n))3.301 0x0012FF7C i int50 0x0012FF78 j int0x0012FF78 0x0012FF74 ptr int*0x0012FF7C 0x0012FF70 ptr1 int**ptr=50 *ptr1=3015.(1)4+30+4=38→40(2)noname50ptr[0]=x;ptr=&x;7.(1)struct Node{int coef;int exp;struct Node*next;}8.(2)i 0 1 2 3 4k=(i+4)%5 4 0 1 2 3array[k]8 1 2 3 5first→5→3→2→1→8→NULL(3)53219.(1)插入中間節點:newnode→next=ptr→next;ptr→next=newnode;(2)刪除中間節點while(current→next!=ptr)current→next=ptr→next;current=ptr→next;
1.int gcd(cint x,int y){int r=x%y;if(r==0)return y;else returngct(t.y);}2.(1)a=0;for(k=1;k < n;k+2=0)for(j=n;j > 0;j/=3)a++ →O(n iog n)(2)i=n;do{a--3;i/=3;}while(a > 0); →O(n)(3)void output(int n){if (n >= 0)output(n/2);elseout << "Poooo"} →O(log n)5.struct Person{int id;char name[30];int age;}struct Person X={2,"小英",50};struct Person Y={3,"noname",20};struct Person ptr[2];ptr[0]=x;(1)→sizeof(x)=4+30+4=38=40(2)輸出=nonamet 50cout << (ptr+1→name << end1;cout << (*pre).age << end1;7.使用含開頭節點環狀串列來處裡多項式(1)Node之定義struct Node{int coef;int exp;struct Node* next;}8.(1)Node之定義?struct Node {int data;struct Node*nxt; }(3)輸出:5.3.2.1
1. gcd(55,121)=115 55 121 255 1100 115112.(2) O(n)3.記憶體 位置 名稱 型態301 0x0012FF7C i int50 0x0012FF78 j int0x0012FF78 0x0012FF74 ptr int*0x0012FF7C 0x0012FF70 ptr1 int**ptr=50 ptr1=3015. (1)4+30+4=38→40(2)noname 507. (1)struct Node{int coef;int exp;struct Node*next;}8.(1) struct Node{int data;struct Node*next;}(2)5 0 1 2 3 4(i+4)%len 4 0 1 2 3Array【k】 8 1 2 3 5first→5 →3 →2 →1 →8 →NULL(3) 5321(9)插入中間節點newnod->next=ptr->next;ptr->next=newnode; 刪除中間節點while(current->next!=ptr) current = current->next;currnet->next = ptr ->next;
1.int gcd (int x, int y){int r = x%y;if return y;elsereturn}5.(1)4+30+4=38→40(2)noname507.(1)sturuct Node{int coef;int exp;sturuct Node*next;}8.(1)struct*Node{int data;struct Node*next;}(2)i 0 1 2 3 4k=(i+4)%5 4 0 1 2 3array[k] 8 1 2 3 5first→5→3→2→1→8→NULL(3)53219.插入中間節點newnode=ptr→next;ptr→next=newnode;刪除中間節點while (current→next!=ptr)current→next=ptr→next;current=ptr→next;
1. gcd(55,121)=115 55 121 255 1100 11511int gcd(int x,int y){int r=x%y;if (r==0)return y;else return gcd(y,r);}5. (1)sizeof(x)=4+30+4=38→407.stuct Nodeint coef;int exp;struct Node*next;8.(1)struct Node{int date;struct Node*next;}(2)First→5→3→2→1→8→NULL(3)5321
1.int gcd(int x,int y){int r=x%y;if (r==0)return y;else return gcd(y,r);}算式:5│55│121│2 │55│110│ ├--┼---┤ │ 0│ 11│ 3.記憶體 位置 名稱 型態301 |0x0012FF7C| i | int50 |0x0012FF78| j |int0x0012FF78|0x0012FF74| ptr |*int0x0012FF7C|0x0012FF70| ptr1 |*int* ptr = 50 * ptr1 = 3015.(1)4+30+4=38→40(2)noname506. 列 欄 值 0 0 1 0 8 3 3 3 3 4 0 77.(1)stuct Node{int coef;int exp;struct Node*next;}8.(2)First→5→3→2→1→8→NULL(3)5 3 2 19.插入中間節點newnod->next=ptr->next;ptr->next=newnode; 刪除中間節點while(current->next!=ptr) current = current->next;currnet->next = ptr ->next;
1.int gcd(int x,int y);{int r=x%y;if(r==0)return y;elsereturn gcd(y,r);}gcd(55,121)=113. 記憶體 位置 名稱 型態301 0*0012FF7C i int50 0*0012FF78 j int0*0012FF78 0*0012FF74 ptr int* 0*0012FF7C 0*0012FF70 ptr1 int**ptr=50 *ptr=3015.(1)sizeof(x)=4+30+4=38→40(2)輸出noname507.(1)struct Node{int coef;int exp;struct Node*next;}8.(1)struct*Node{int data;struct Node*next;}(2)i 0 1 2 3 4k=(i+4)%5 4 0 1 2 3array[k] 8 1 2 3 5first→5→3→2→1→8→NULL(3)5321
1.int gcd ( int x , int y ){int r = x % y ;if ( r = = 0 )return y ;elsereturn gcd ( y , r ) ;}gcd ( 55 , 121 ) = 115 55 121 255 1100 11511Ans:112.(2)i=n;do{ a-=3;i/=3;}while(a>0);Ans: O(n)5. (1)sizeof(x)=4+30+4=38→40(2)輸出noname507. (1)stuct Nodeint coef;int exp;struct Node*next;8. (2) i 0 1 2 3 4k=(i+4)%5 4 0 1 2 3array[k] 8 1 2 3 5first→5→3→2→1→8→NULL(3) 53219. (1)插入中間節點:newnode→next=ptr→next;ptr→next=newnode;(2)刪除中間節點while(current→next!=ptr)current→next=ptr→next;current=ptr→next;
1.int gcd(int x,int y) {int r=x%y; if (r==0)return y; else return gcd(y,r); }5│55│121│2 │55│110│ ├─ ┼── ┤ │ 0│ 11│ 2. (2) 0(n)3.記憶體 位置 名稱 型態 301 0x0012FF7C i int 50 0x0012FF78 j int0x0012FF78 0x0012FF74 ptr *int0x0012FF7C 0x0012FF70 ptr1 *int* ptr = 50 * ptr1 = 3015.(1)4+30+4=38→40(2)noname507.(1)Node之定義:struct Node{ int coef;int exp;struct Node* next;};8.(2) i 0 1 2 3 4k=(i+4)%len 4 0 1 2 3array[k] 8 1 2 3 5 first→5→3→2→1→8→NULL(3)輸出53219. 刪除中間節點while (current → next != ptr)current = current → next;cuttent → next = ptr → next;
2.O(nlogn),O(n),O(logn)5. (1)sizeof(x)=4+30+4=38→40(2)輸出noname,507. (1)stuct Nodeint coef;int exp;struct Node*next;8. (2) i 0 1 2 3 4k=(i+4)%5 4 0 1 2 3 array[k] 8 1 2 3 5first→5→3→2→1→8→NULL(3) 53219.(2)刪除中間節點while(current→next!=ptr)current→next=ptr→next;current=ptr→next;
1.int gcd(int x,int y){int r=x%y;if (r==0)return y;else return gcd(y,r);}5│55│121│2 │55│110│ ├─┼─-┤ │ 0│ 11│ 2. (2) 0(n)3.記憶體 位置 名稱 型態301 0x0012FF7C i int50 0x0012FF78 j int0x0012FF78 0x0012FF74 ptr *int0x0012FF7C 0x0012FF70 ptr1 *int* ptr = 50 * ptr1 = 3016.row col value0 0 70 8 33 3 34 0 75.(2)noname 507.(1)sturuct Node{int coef;int exp;sturuct Node*next;}(3) 所有節點都是中間節點8.(2) i 0 1 2 3 4k=(i+4)%len 4 0 1 2 3array[k] 8 1 2 3 5 first→5→3→2→1→8→NULL(3)輸出53219.插入中間節點newnod->next=ptr->next;ptr->next=newnode; 刪除中間節點while (current → next != ptr)current = current → next;cuttent → next = ptr → next;
1.int gcd(int x,int y){int r=x%y;if (r==0)return y;else return gcd(y,r);}算式:5│55│121│2 │55│110│ ├─┼──┤ │ 0│ 11│ 5.(1)4+30+4=38→40(2)noname507.(1)sturuct Node{int coef;int exp;sturuct Node*next;}8.(1)struct Node{int date;struct Node*next;}(2)First→5→3→2→1→8→NULL(3)5321
1. gcd(55,121)=115 55 121 255 1100 115113.記憶體 位置 名稱 型態301 0x0012FF7C i int50 0x0012FF78 j int0x0012FF78 0x0012FF74 ptr int*0x0012FF7C 0x0012FF70 ptr1 int**ptr=50 ptr1=3015.(2)noname506. row col value0 0 70 8 33 3 30 4 77. (1)struct Node{int coef;int exp;struct Node*next;}(3)所有節點都是中間節點8.(2) i 0 1 2 3 4k=(i+4)%5 4 0 1 2 3array[k] 8 1 2 3 5first->5->3->2->1->8->NULL8.(3)5321
HTML 編輯器
1. gcd(55,121)=11
回覆刪除5 55 121 2
55 110
0 115
11
5. (1)sizeof(x)=4+30+4=38→40
(2)輸出noname
50
7. (1)stuct Node
int coef;
int exp;
struct Node*next;
8. (2) i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→NULL
(3) 5
3
2
1
9. (1)插入中間節點:
newnode→next=ptr→next;
ptr→next=newnode;
(2)刪除中間節點
while(current→next!=ptr)
current→next=ptr→next;
current=ptr→next;
1.int gcd(int x,int y)
回覆刪除{int r=x%y;
if (r==0)return y;
else return gcd(y,r);
}
算式:
5│55│121│2
│55│110│
├─┼──┤
│ 0│ 11│
5.(1)
4+30+4=38→40
(2)
noname
50
7.(1)
sturuct Node{
int coef;
int exp;
sturuct Node*next;
}
8.(1)
struct Node{
int date;
struct Node*next;
}
(2)
First→5→3→2→1→8→NULL
(3)
5
3
2
1
9.刪除中間節點
while(current→next!=ptr)
current=current→next;
cuttent→next=ptr→next;
1.
回覆刪除int gcd ( int x , int y )
{
int r = x % y ;
if ( r = = 0 )
return y ;
else
return gcd ( y , r ) ;
}
gcd ( 55 , 121 ) = 11
5.(2)
noname
50
7.(1)
struct Node {
int coef ;
int exp ;
struct Node *next ;
}
8.(2)
i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k] 8 1 2 3 5
first->5->3->2->1->8->NULL
8.(3)
5
3
2
1
題目2.
回覆刪除(2)i=n;
do{ a-=3;
i/=3;
}while(a>0);
Ans: O(n)
題目3.
記憶體 位置 名稱 型態
301 0x0012FF7C i int
50 0x0012FF78 j int
0x0012FF78 0x0012FF74 ptr *int
0x0012FF7C 0x0012FF70 ptr1 *int
* ptr = 50 * ptr1 = 301
題目7.
(1)Node之定義:
struct Node
{ int coef;
int exp;
struct Node* next;
};
題目8.
(2)
i 0 1 2 3 4
k=(i+4)%len 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→NULL
(3)輸出
5
3
2
1
2. (2) 0(n)
回覆刪除3.
記憶體 位置 名稱 型態
301 0x0012FF7C i int
50 0x0012FF78 j int
0x0012FF78 0x0012FF74 ptr int*
0x0012FF7C 0x0012FF70 ptr1 int*
*ptr=50 ptr1=301
5. (1)4+30+4=38→40
(2)noname 50
7. (1)struct Node{
int coef;
int exp;
struct Node*next;
}
(3)所有節點都是中間節點
8.(1) struct Node{
int data;
struct Node*next;
}
(2)
5 0 1 2 3 4
(i+4)%len 4 0 1 2 3
Array【k】 8 1 2 3 5
first→5 →3 →2 →1 →8 →NULL
(3) 5
3
2
1
第一題
回覆刪除int gcd(int x, int y)
{int r=x%y;
if(r==0)
return y;
else
return gcd(y,r);
}
121/55=2...餘11 (121,11)
121/11=11...餘0 (121,11)
Ans 11
第七題
struct Node
{int coef;
int exp;
struct Node*next;
}
第三題
sizeof(int)=4(bytes)
int i=301;
int j-i/6;
int*ptr=&j;
int*ptr=&i;
記憶體 位置 名稱 型態
301 Ox0012FF7C i int
50 Ox0012FF78 j int
Ox0012FF78 Ox0012FF74 ptr int*
Ox0012FF7C Ox0012FF70 ptr1 int*
*ptr=50 *ptr1=301
第八題
i 0 1 2 3 4
(i+4)%len 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→NULL
輸出
5
3
2
1
1.
回覆刪除int gcd(int x,int y);
{
int r=x%y;
if(r==0)
return y;
else
return gcd(y,r);
}
gcd(55,121)=11
3.
記憶體 位置 名稱 型態
301 0*0012FF7C i int
50 0*0012FF78 j int
0*0012FF78 0*0012FF74 ptr int*
0*0012FF7C 0*0012FF70 ptr1 int*
*ptr=50 *ptr=301
5.
(1)sizeof(x)=4+30+4=38→40
(2)輸出
noname
50
7.
(1)
struct Node
{
int coef;
int exp;
struct Node*next;
}
8.
(1)
struct*Node
{
int data;
struct Node*next;
}
(2)
i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→NULL
(3)
5
3
2
1
1.
回覆刪除int gcd (int x,y ){
int r=x%y;
if (r==0) return y;
else
return ( y , r ) ;
}
5|55|121|2
|55|110|
| 0| 11|
5.
(1).40
(2).noname
50
7.
(1).
struct node;{
int coef;
int exp;
struct node*next;
}
8.(2).
i 0 1 2 3 4
i+4%5 4 0 1 2 3
array[k]8 1 2 3 5
first→5→3→2→1→8→NULL
(3).
5
3
2
1
(9).插入中間節點
newnod->next=ptr->next;
ptr->next=newnode;
刪除中間節點
while(current->next!=ptr)
current = current->next;
currnet->next = ptr ->next;
1. int gcd (int x, int y)
回覆刪除{
int r=x%y
if (r==0) return y;
else return gcd (y,r);
}
gcd(55,121)=11
2. (2)O(n)
3. 記憶體 位置 名稱 型態
301 0x0012FF7C i int
50 0x0012FF78 j int
0x0012FF78 0x0012FF74 ptr int*
0x0012FF7C 0x0012FF70 ptr1 int*
*ptr=50 *ptr1=301
5. (1)4+30+4=38→40
6. row col value
0 0 7
0 8 3
3 3 3
0 4 7
7. (1) struct Node{
int coef;
int exp;
struct Node *next;
}
(3) 所有節點都是中間節點。
8. (2)first→5→3→2→1→8→NULL
(3) 5
3
2
1
9. 插入中間節點
newnode=ptr→next;
ptr→next=newnode;
刪除中間節點
while (current→next!=ptr)
current→next=ptr→next;
current=ptr→next;
1.
回覆刪除int gcd (int x, int y)
{
int r = x%y;
if return y;
else
return
}
2. i=n;
do{
a-=3;
i/=3;
}while(a>0);
On
3. 記憶體 位置 名稱 型態
301 0x0012FF7C i int
50 0x0012FF78 j int
0x0012FF78 0x0012FF74 ptr *int
0x0012FF7C 0x0012FF70 ptr1 *int
* ptr = 50 * ptr1 = 301
5.
a. 4+30+4=38 b. noname
38+2=40 50
sizeof(x)=40
4. float d[9*12];
int n=9 , k=12
…
for(i=0; i<n; i++)
for(j=0; j<k; j++)
d[i*k+j]=(float) fun(i)/fun(j);
6.
(1)
struct Node{
int coef;
int exp;
struct Node*new
}
(3)因為所有節點都變成中間節點,變成只要處理中間節點
8.
(1) struct Node{ (2) i 0 1 2 3 4 (3)
int data; k=(i+4)%5 4 0 1 2 3 5
struct Node*new; array[k] 8 1 2 3 5 3
} first->5->3->2->1->8->Null 2
1
9.
while(current->next!=ptr)
current = current->next;
current->next = ptr->next;
3.
回覆刪除記憶體 位置 名稱 型態
301 0x0012FF7C i int
50 0x0012FF78 j int
0x0012FF78 0x0012FF74 ptr int*
0x0012FF7C 0x0012FF70 ptr1 int*
*ptr=50 *ptr1=301
5.
(1)4+30+4=38→40
(2)noname
50
sizeof(x)=40
7.(1)struct Node{
int coef;
int exp;
struct Node* next;
}
8.(1)struct Node{
int data;
struct Node*next;
}
(2) i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→NULL
(3) 5
3
2
1
9.插入中間節點:
newnode→next=ptr→next;
ptr→next=newnode;
刪除中間節點:
While(current→next!=ptr)
current=current→next;
current→next=ptr→next;
1.
回覆刪除int gcd (int x , int y)
{
int r = x % y ;
if(r = = 0) return y;
else return gcd (y , r);
}
ANS:
x y
55 121
r=55
121 55
r=11
55 11
r=55
y=11
2.
i = n;
do {
a-=3;
i/=3;}
while (a>0);
ANS:
O(n)
3.
記憶體 位置 名稱 型態
301 0*0012FF7C i int
50 0*0012FF78 j int
0*0012FF78 0*0012FF74 ptr int*
0*0012FF7C 0*0012FF70 ptr1 int*
ANS:
*ptr=50 *ptr1=301
5.
(1)size of (x) = 4+30+4 = 38 → 40
(2)noname
50
7.
(1)
struct Node {
int coef;
int exp;
struct Node*next;
}
8.
(2)
i 0 1 2 3 4
k=(1+4%5) 4 0 1 2 3
array 8 1 2 3 5
first → 5 → 3 → 2 → 1 → 8 → NULL
(3)
5 3 2 1
5.
回覆刪除(1)
4+30+4=38
因為要四的倍數所以等於40
7.
(1)
struct node
{
int coff;
int exp;
struct node *next
};
8.
(2)
first->5->3->2->1->8->NULL
(3)5
3
2
1
題目1.
回覆刪除----------------------------------
int gcd (int x, int y)
{
int r = y % x ;
if (r==0)
return x;
else
retutn gcd(x,r);
}
計算
2|121|55|5
|110|55|
|---|--|
| 11| 0|
----------------------------------
題目2.(2)
----------------------------------
i=n;
do{
a-=3;
i/=3;
}while (a>0);
ANS:O(n)
----------------------------------
題目3.
----------------------------------
記憶體 、 位置 、 名稱、 型態
301、 0x0012FF7C 、 i 、int
50 、 0x0012FF78 、 j 、 int
0x0012FF78 、0x0012FF74 、ptr 、 int*
0x0012FF7C、 0x0012FF70 、 ptr1 、int*
ptr=50 ptr1=301
----------------------------------
題目5.(1)
----------------------------------
4+30+4=38 → 40
----------------------------------
題目6.
----------------------------------
列 欄 值
0 0 7
0 8 3
3 3 3
4 0 7
----------------------------------
題目7.(1)
----------------------------------
struct Node
{
int coef;
int exp;
struct Node* next;
}
----------------------------------
題目8.
----------------------------------
i : 0 、 1 、2、 3 、 4
(i+4)%5 : 4、 0 、 1 、 2 、 3
array[k]: 8 、1 、 2 、3 、5
(2) first → 5 → 3 → 2 → 1 → 8 → NULL
(3)
5
3
2
1
----------------------------------
1. gcd(55,121)=11
回覆刪除5 55 121 2
55 110
0 115
11
2.
0(nlogn) 0(n)
3.
50 0x0012FF78
0x0012FF78 0x0012FF74
0x0012FF7C 0x0012FF70
*ptr=50 *ptr1=301
5.
(1)sizeof(x)=4+30+4=38→40
(2)輸出noname
50
6.
row 0034
col 0830
vol 7337
7.
(1)stuct Node
int coef;
int exp;
struct Node*next;
8.
(1)
struct Node{
int data;
struct Node*next;
}
(2)
i 01234
k=(i=4)%5 40123
array[k] 81235
first→5→3→2→1→8→NULL
(3)
5
3
2
1
9.
(1)插入中間節點:
newnode→next=ptr→next;
ptr→next=newnode;
(2)刪除中間節點
while(current→next!=ptr)
current→next=ptr→next;
current=ptr→next;
1.gcd(55,121)=11
回覆刪除5︳55︳121︳2
︳55︳110︳
︳ 0︳ 11︳
2. (2.)
i=n;
do{
a-=3;
i/=3;
while(a>0);
Big O=O(n)
3.
sizeof(int)=4(bytes)
int i=301;
int j-i/6;
int*ptr=&j;
int*ptr=&i;
記憶體 位置 名稱 型態
301 |0x0012FF7C| i int
50 |0x0012FF78| j int
0x0012FF78| 0x0012FF74| ptr int*
0x0012FF7C| 0x0012FF70| ptr1 int*
5.
(1)sizeof(x)=4+30+4=38→40
8.
(2)
i → 0 1 2 3 4
k=(i+4)%5→ 4 0 1 2 3
array[k] → 8 1 2 3 5
first→5→3→2→1→8→NULL
(3)
5
3
2
1
5.(1)4+30+4=38-佔40個位元
回覆刪除8.(2)
i:0 1 2 3 4
k=(i+4)%5:4 0 1 2 3
array[k]:8 1 2 3 5
first→5→3→2→1→8→Null
(3)
5
3
2
1
1.int gcd(intx, inty)
回覆刪除{
int r=x%y;
if(r==0)return y;
else return gcd(y,r);
}
gcd(55,121)=11
2.0(nlogn)
0(n)
0(logn)
3. 301 0x0012FF7C i int
50 0x0012FF78 j int
0x0012FF78 0x0012FF74 ptr int*
0x0012FF7C 0x0012FF70 ptr int*
*prt = 50 *ptr1 = 301
5. 4+30+4 =38
sizeof(X)=40
noname
50
7. struct Node
{
int coef;
int exp;
struct Node*next;
}
8. i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k] 8 1 2 3 5
first-5-3-2-1-8-NULL
5 3 2 1
9. 刪除中間節點
while(current->next!=ptr)
current=current->next;
current->next=ptr->next;
插入中間節點
newnode->next=ptr->next;
ptr->next=newnode;
1. gcd(55,121)=11
回覆刪除5 55 121 2
55 110
0 115
11
2.(2)O(n)
3.
301 0x0012ff7c
50 0x0012ff78
0x0012ff78 0x0012ff74
0x0012ff7c 0x0012ff70
*ptr=50 *ptr1=301
4.float[9*12]; c[i*k+j]=(float)fun(i)/fun(j);
5. (1)sizeof(x)=4+30+4=38→40
(2)輸出noname
50
7. (1)stuct Node
int coef;
int exp;
struct Node*next;
8. (2) i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→NULL
(3) 5
3
2
1
9. (1)插入中間節點:
newnode→next=ptr→next;
ptr→next=newnode;
(2)刪除中間節點
while(current→next!=ptr)
current→next=ptr→next;
current=ptr→next;
1.gcd(55,121)=11
回覆刪除5 55 121 2
55 110
0 11
2.
(1)O(n longn)
5.(2)輸出=noname
50
7.
(1)struct Node{
int coef;
int exp;
struct Node*next;
}
(3)所有節點都是中間節點
8.
(2)
i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→Null
(3)
5
3
2
1
1.
回覆刪除gcd(55,121)=11
5│55│121│2
.│55│110│
.│ 0│ 11│
int gcd(int x,int y)
{
int r=x%y;
if(r==0)x%y;
if(r==0)returny;
else retum grd(y,r);
}
2.
(1)O( n log n )
(2)O(n)
5.
(1)sizef(x)=4+30+4=38→40
(2)輸出
noname
50
7.
(1)struct Node{
int coef;
int exp;
struct Node* next;
}
(3)使用開頭節點的環狀串列之優點:所有節點都是中間節點。
8.
(1)struct Node{
int data a;
struct Node* next;
}
(2) i│0 1 2 3 4
k=(i+4)%5│4 0 1 2 3
array[k] │8 1 2 3 5
first→5→3→2→1→8→NULL
(3)
5
3
2
1
9.
插入中間節點:
newnode→next=ptr→next;
prt→next=newnode;
刪除中間節點:
while(current=current→next;
current→next=prt→next;)
1. int gcd(int x,int y)
回覆刪除{
int r==x%y;
if (r==0) return y;
else return gcd(y,r);
}
5|55|121|2 gcd(55,121)=11
|55|110|
| 0| 11|
3. 記憶體 位置 名稱 型態
301 | 0x0012FF7C | i int
50 | 0x0012FF78 | j int
0x0012FF78 | 0x0012FF74 | ptr *int
0x0012FF7C | 0x0012FF70 | ptr1 *int
*ptr=50 *ptr1=301
5. (1)4+30+4=38→40
(2)noname
50
7. struct Node{
int coef;
int exp;
struct Node*next;
}
8.(1) struct Node{
int data;
struct Node*next;
}
(2) i | 0 1 2 3 4
k=(i+4)%5| 4 0 1 2 3
array[k] | 8 1 2 3 5
first→5→3→2→1→8→NULL
(3)5
3
2
1
9. 刪除中間節點
while(current→next!=ptr)
current=current→next;
cuttent→next=ptr→next;
(1)struct Node{
回覆刪除int data;
struct Node*next;
}
(2) i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→NULL
(3) 5
3
2
1
8.
回覆刪除(1)struct Node{
int data;
struct Node*next;
}
(2) i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→NULL
(3) 5
3
2
1
題目一
回覆刪除int gcd (int x,y ){
int r=x%y;
if (r==0) return y;
else
return ( y , r ) ;
}
5|55|121|2
|55|110|
| 0| 11|
題目三
記憶體 位置 名稱 型態
301 0*0012FF7C i int
50 0*0012FF78 j int
0*0012FF78 0*0012FF74 ptr int*
0*0012FF7C 0*0012FF70 ptr1 int*
*ptr=50 *ptr=301
題目五
(1)sizeof(x)=4+30+4=38→40
(2)輸出
noname
50
題目七
(1) struct Node{
int coef;
int exp;
struct Node *next;
}
(3) 所有節點都是中間節點
題目八
(2)first→5→3→2→1→8→NULL
(3) 5
3
2
1
題目九
插入中間節點
newnode=ptr→next;
ptr→next=newnode;
刪除中間節點
while (current→next!=ptr)
current→next=ptr→next;
current=ptr→next;
題目1.
回覆刪除struct*gcd(int x,int y)}
int r;
r=(x%y);
if(r==0)
return y
else
return gcd(y,r);
{
題目2.
1.0(nlogn) 2.0(n) 3.0(logn)
題目5.
1. 4+30+4=38→40
2. noname 50
題目7.
sturuct Node{
int coef;
int exp;
sturuct Node*next;
}
題目8.
(1) struct Node{
int data;
struct Node*next;
}
(2)
i 0 1 2 3 4
(i+4)%len 4 0 1 2 3
array[k] 8 1 2 3 5
first→5 →3 →2 →1 →8 →NULL
(3)
5
3
2
1
第一題
回覆刪除int gcd(int x,int y)
{int r=x%y;
if (r==0)return y;
else return gcd(y,r);
}
第二題
1) O(n log n) 2) O(n) 3) O(log n)
第五題
(1)sizeof(x)=4+30+4=38→40
(2)輸出
noname
50
第七題
sturuct Node{
int coef;
int exp;
sturuct Node*next;
}
第八題
1)
struct*Node
{
int data;
struct Node*next;
}
2)
i 0 1 2 3 4
(i+4)%len 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→NULL
輸出
5
3
2
1
第九題
源碼
while(current→next!=ptr)
current=current→next;
cuttent→next=ptr→next;
1. gcd(55,121)=11
回覆刪除5 55 121 2
55 110
0 115
11
(2)
i=n;
do{ a-=3;
i/=3;
}while(a>0);
Ans: O(n)
3.
記憶體 位置 名稱 型態
301 0x0012FF7C i int
50 0x0012FF78 j int
0x0012FF78 0x0012FF74 ptr *int
0x0012FF7C 0x0012FF70 ptr1 *int
* ptr = 50 * ptr1 = 301
8.
i 0 1 2 3 4
(i+4)%len 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→NULL
輸出
5
3
2
1
9.
(1)插入中間節點:
newnode→next=ptr→next;
ptr→next=newnode;
(2)刪除中間節點
while(current→next!=ptr)
current→next=ptr→next;
current=ptr→next;
1. int gcd(intx,inty)
回覆刪除{
int r=x%y;
if(r==0)return y;
else return gcd(y,r);
}
2.(2)
O(n)
3.
記憶體 位置 名稱 型態
301 0x0012ff7c i int
50 0x0012ff78 j int
0x0012ff78 0x0012ff74 ptr int*
0x0012ff74 0x0012ff70 ptr1 int*
*ptr=50 *ptr1=301
4.
float d[108];
int n=9,k=12;
for(i=0;i < n;i++)
for(j=0;j < k;j++)
d[i*l+j]=float fun(i)/fun(j);
5.
(1)
sizeof(x)=4+30+4=38--->40
(2)
noname 50
7.
(1)
struct Node {
int coef;
int exp;
struct Node*next;
(2)
所有節點都是中間節點
8.
(2)
i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k] 8 1 2 3 5
first->5->3->2->1->8->NULL
(3)
5
3
2
1
9.
插入: next->next=ptr->next;
Newnode=ptr->next;
刪除: while(current->next!=ptr)
current=current->next;
current->next=ptr->next;
1. int gcd(intx,inty)
回覆刪除{
int r=x%y;
if(r==0)return y;
else return gcd(y,r);
}
2.(2)
O(n)
3.
記憶體 位置 名稱 型態
301 0x0012ff7c i int
50 0x0012ff78 j int
0x0012ff78 0x0012ff74 ptr int*
0x0012ff74 0x0012ff70 ptr1 int*
*ptr=50 *ptr1=301
4.
float d[108];
int n=9,k=12;
for(i=0;i < n;i++)
for(j=0;j < k;j++)
d[i*l+j]=float fun(i)/fun(j);
5.
(1)
sizeof(x)=4+30+4=38--->40
6.
row col value
0 0 7
0 8 3
3 3 3
4 0 7
7.
(1)
struct Node {
int coef;
int exp;
struct Node*next;
(2)
所有節點都是中間節點
8.
(2)
i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k] 8 1 2 3 5
first->5->3->2->1->8->NULL
(3)
5
3
2
1
9.
插入: next->next=ptr->next;
Newnode=ptr->next;
刪除: while(current->next!=ptr)
current=current->next;
current->next=ptr->next;
7
回覆刪除(1)
Node之定義?
struct Node{
int coef;
int exp;
struct Node* next;
}
8
(2)
first-> 5-> 3-> 2-> 1-> 8-> NULL
(3)
5
3
2
1
1.
回覆刪除int gcd(int x,int y)
{int r=x%y;
if (r==0)return y;
else return gcd(y,r);
}
2.
(1)o(nlogn) (2) o(n) (3) o(logn)
3.
記憶體 位置 名稱 型態
301 0x0012FF7C i int
50 0x0012FF78 j int
0x0012FF78 0x0012FF74 ptr *int
0x0012FF7C 0x0012FF70 ptr1 *int
* ptr = 50 * ptr1 = 301
4.
float d[108];
int n=9 、k=12
…
for(i=0; i<n; i++)
for(j=0; j<k; j++)
d[i*k+j]=(float) fun(i)/fun(j);
5.
1)sizeof(x)=4+30+4=38→40
(2)輸出noname
50
7.
(1) struct Node{
int coef;
int exp;
struct Node *next;
}
(3) 所有節點都是中間節點。
8.
(2)first→5→3→2→1→8→NULL
(3) 5.3.2.1
9.
插入中間節點
newnode=ptr→next;
ptr→next=newnode;
刪除中間節點
while (current→next!=ptr)
current→next=ptr→next;
current=ptr→next;
1. int gcd (int x,int y)
回覆刪除{ int r=x%y;
if (r= =o)return y;
else return gcd (y,r);
}
2.(1)0(n logn)(2)0(n)(3)0(logn)
3.記憶體 位置 名稱 型態
30 0x0012FF7C i int
50 0x0012FF78 j int
0x0012FF78 0x0012FF74 ptr int*
0x0012FF74 0x0012FF70 ptr1 int*
4.float[9*12]; c[i*k+j]=(float)fun(i)/fun(j);
5.(2)noname 50
6.row col val
0 0 7
0 8 3
3 3 3
4 0 7
7.(1)struct Node{
int coef;
int exp;
struct Node*next;
}
8.(2) i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array 8 1 2 3 5
1.
回覆刪除int gcd (int x, int y)
gcd(55,121)=11
int r=x%y; if(r==0) return;
else return gcd (y,r);
5│55│121│2
│55│121│
=============
│0 │11│
2.
0(n logn)
0(n)
0(log n)
5.
(1)4+30+4=38-->40
(2)noname
50
7.(1)
stuct Node{
int coef;
int exp;
struct Node*next;
}
(3)所有節點都是中間節點
8.
(2) i │ 01234
k=(i+4)55│ 40123
array[k] │ 81235
(3)
5
3
2
1
9.插入中間節點
newnod->next=ptr->next;
ptr->next=newnode;
1.
回覆刪除int gcd (int x, int y)
{
int r=x%y
if (r==0) return y;
else return gcd (y,r);
}
gcd(55,121)=11
2.
(1)
o(n logn)
(2)
O(n)
3.
記憶體 位置 名稱 型態
301 0x0012FF7C i int
50 0x0012FF78 j int
0x0012FF78 0x0012FF74 ptr *int
0x0012FF7C 0x0012FF70 ptr1 *int
* ptr = 50 * ptr1 = 301
5.
(1)sizeof(x)=4+30+4=38→40
(2)輸出noname= 50
7.
dtruct Node{
int coef;
int exp;
struct Node*next;
}
8.
(1)
struct Node{
int data;
struct Node*next;
}
(2)
i 0 1 2 3 4
k=i+4%5 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→NULL
(3)
5
3
2
1
9.
刪除中間節點
while (current→next!=prt)
current→next=ptr→next;
current=ptr→next;
1. 5│55│121│2
回覆刪除│55│110│
├─┼──┤
│ 0│ 11│
int gcd(int x,int y)
{int r=x%y;
if (r==0)return y;
else return gcd(y,r);
}
2-2 O(n)
5-1 4+30+4=38→40
5-2 n0name
50
7-1 stuct Node
int coef;
int exp;
struct Node*next;
7-3 所有節點都是中間節點
8-1
struct Node{
int date;
struct Node*next;
}
8-2
first→5→3→2→1→8→NULL
8-3
5
3
2
1
9-2
while(current→next!=ptr)
current=current→next;
cuttent→next=ptr→next;
1.
回覆刪除int gcd(int x,int y)
{int r=x%y;
if (r==0) return y;
else return gcd(y,r);
}
5.
(1)sizeof(x)=40
(2)
noname
50
6.
欄 列 值
0 0 7
0 8 3
3 3 3
4 0 7
7.
struct Node{
int coef;
int exp;
struct Node*next;
}
8.(2)
i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k] 8 1 2 3 5
(3)
5
3
2
1
9.while(current->next!=ptr)
current=current->next;
current->next=ptr->next;
1.
回覆刪除gcd( int x,int y )
{
r=x % y;
if( r==0 )
return y;
else
return gcd ( y,r );
5.
(1)30+4+4=38 40-->要四倍數
(2)noname
50
7.
struct Node {
int coef;
int exp;
struct Node* next;
}
8.
(1)
struct Node
{
int data
struct Node* next;
};
(2)
frist->5->3->2->1->8->NULL
(3)
5
3
2
1
9.
插入: next->next=ptr->next;
Newnode=ptr->next;
刪除: while(current->next!=ptr)
current=current->next;
current->next=ptr->next;
1.
回覆刪除int gcd(int x,int y)
{
int r=x%y;
if (r==0)
return y;
else
return gcd(y,r) ;
}
gcd (55,121) = 11
2.
(1)O(nlogn)
(2)O(n)
(3)O(logn)
5. sizeof(x)=4+30+4=38→40
7.
(1) struct Node{
int coef;
int exp;
struct Node* next;}
1.
回覆刪除int gcd(int x,int y);
{
int r=x%y;
if(r==0)
return y;
else
return gcd(y,r);
}
gcd(55,121)=11
4. float d[9*12];
int n=9 , k=12
for(i=0; i<n; i++)
for(j=0; j<k; j++)
d[i*k+j]=(float) fun(i)/fun(j);
5. (1)sizeof(x)=4+30+4=38→40
(2)輸出noname
50
7.(1)
struct Node
{
int coef;
int exp;
struct Node*next;
}
8. (2)first→5→3→2→1→8→NULL
(3) 5
3
2
1
9.刪除中間節點
while (current→next!=ptr)
current→next=ptr→next;
current=ptr→next;
1.
回覆刪除int gcd ( int x , int y )
{
int r = x % y ;
if ( r = = 0 )
return y ;
else
return gcd ( y , r ) ;
}
gcd ( 55 , 121 ) = 11
5 55 121 2
55 110
0 115
11
Ans:11
2.
(2)i=n;
do{ a-=3;
i/=3;
}while(a>0);
Ans:O(n)
3.
記憶體 位置 名稱 型態
301 0x0012FF7C i int
50 0x0012FF78 j int
0x0012FF78 0x0012FF74 ptr int*
0x0012FF7C 0x0012FF70 ptr1 int*
*ptr=50 *ptr1=301
5.
(2)輸出
noname
50
7.
(1)
struct Node
{
int coef;
int exp;
struct Node*next;
}
8.
(2)
i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k]8 1 2 3 5
first→5→3→2→1→8→NULL
(3)
5
3
2
1
9.
(1)插入中間節點:
newnode→next=ptr→next;
ptr→next=newnode;
(2)刪除中間節點
while(current→next!=ptr)
current→next=ptr→next;
current=ptr→next;
1.
回覆刪除int gcd(int x,int y)
{int r=x%y;
if (r==0)return y;
else return gcd(y,r);
}
算式:
5│55│121│2
│55│110│
│──┼───┤
│ 0│ 11│
2.
(1)
o(n)*o(log n)
=o(n(log n))
3.
301 0x0012FF7C i int
50 0x0012FF78 j int
0x0012FF78 0x0012FF74 ptr int*
0x0012FF7C 0x0012FF70 ptr1 int*
*ptr=50 *ptr1=301
5.
(1)4+30+4=38→40
(2)noname
50
ptr[0]=x;
ptr=&x;
7.
(1)
struct Node
{
int coef;
int exp;
struct Node*next;
}
8.
(2)
i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k]8 1 2 3 5
first→5→3→2→1→8→NULL
(3)
5
3
2
1
9.
(1)插入中間節點:
newnode→next=ptr→next;
ptr→next=newnode;
(2)刪除中間節點
while(current→next!=ptr)
current→next=ptr→next;
current=ptr→next;
1.
回覆刪除int gcd(cint x,int y)
{int r=x%y;
if(r==0)return y;
else return
gct(t.y);}
2.
(1)
a=0;
for(k=1;k < n;k+2=0)
for(j=n;j > 0;j/=3)
a++
→O(n iog n)
(2)
i=n;do{a--3;
i/=3;}
while(a > 0);
→O(n)
(3)
void output(int n)
{if (n >= 0)
output(n/2);
else
out << "Poooo"}
→O(log n)
5.
struct Person
{int id;
char name[30];
int age;}
struct Person X={2,"小英",50};
struct Person Y={3,"noname",20};
struct Person ptr[2];
ptr[0]=x;
(1)
→sizeof(x)=4+30+4=38=40
(2)
輸出=nonamet 50
cout << (ptr+1→name << end1;
cout << (*pre).age << end1;
7.
使用含開頭節點環狀串列來處裡多項式
(1)
Node之定義
struct Node
{int coef;
int exp;
struct Node* next;}
8.
(1)Node之定義?
struct Node {int data;
struct Node*nxt; }
(3)輸出:
5.3.2.1
1.
回覆刪除gcd(55,121)=11
5 55 121 2
55 110
0 115
11
2.
(2) O(n)
3.
記憶體 位置 名稱 型態
301 0x0012FF7C i int
50 0x0012FF78 j int
0x0012FF78 0x0012FF74 ptr int*
0x0012FF7C 0x0012FF70 ptr1 int*
*ptr=50 ptr1=301
5.
(1)4+30+4=38→40
(2)noname 50
7.
(1)struct Node{
int coef;
int exp;
struct Node*next;
}
8.
(1)
struct Node{
int data;
struct Node*next;
}
(2)
5 0 1 2 3 4
(i+4)%len 4 0 1 2 3
Array【k】 8 1 2 3 5
first→5 →3 →2 →1 →8 →NULL
(3)
5
3
2
1
(9)
插入中間節點
newnod->next=ptr->next;
ptr->next=newnode;
刪除中間節點
while(current->next!=ptr)
current = current->next;
currnet->next = ptr ->next;
1.int gcd (int x, int y){
回覆刪除int r = x%y;
if return y;
else
return
}
5.(1)
4+30+4=38→40
(2)
noname
50
7.(1)
sturuct Node{
int coef;
int exp;
sturuct Node*next;
}
8.
(1)
struct*Node
{
int data;
struct Node*next;
}
(2)
i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→NULL
(3)
5
3
2
1
9.
插入中間節點
newnode=ptr→next;
ptr→next=newnode;
刪除中間節點
while (current→next!=ptr)
current→next=ptr→next;
current=ptr→next;
1.
回覆刪除gcd(55,121)=11
5 55 121 2
55 110
0 115
11
int gcd(int x,int y)
{int r=x%y;
if (r==0)return y;
else return gcd(y,r);
}
5.
(1)sizeof(x)=4+30+4=38→40
7.
stuct Node
int coef;
int exp;
struct Node*next;
8.
(1)struct Node{
int date;
struct Node*next;
}
(2)
First→5→3→2→1→8→NULL
(3)
5
3
2
1
1.
回覆刪除int gcd(int x,int y)
{int r=x%y;
if (r==0)return y;
else return gcd(y,r);
}
算式:
5│55│121│2
│55│110│
├--┼---┤
│ 0│ 11│
3.
記憶體 位置 名稱 型態
301 |0x0012FF7C| i | int
50 |0x0012FF78| j |int
0x0012FF78|0x0012FF74| ptr |*int
0x0012FF7C|0x0012FF70| ptr1 |*int
* ptr = 50 * ptr1 = 301
5.(1)
4+30+4=38→40
(2)
noname
50
6.
列 欄 值
0 0 1
0 8 3
3 3 3
4 0 7
7.
(1)
stuct Node{
int coef;
int exp;
struct Node*next;
}
8.
(2)
First→5→3→2→1→8→NULL
(3)
5 3 2 1
9.
插入中間節點
newnod->next=ptr->next;
ptr->next=newnode;
刪除中間節點
while(current->next!=ptr)
current = current->next;
currnet->next = ptr ->next;
1.
回覆刪除int gcd(int x,int y);
{
int r=x%y;
if(r==0)
return y;
else
return gcd(y,r);
}
gcd(55,121)=11
3.
記憶體 位置 名稱 型態
301 0*0012FF7C i int
50 0*0012FF78 j int
0*0012FF78 0*0012FF74 ptr int*
0*0012FF7C 0*0012FF70 ptr1 int*
*ptr=50 *ptr=301
5.
(1)sizeof(x)=4+30+4=38→40
(2)輸出
noname
50
7.
(1)
struct Node
{
int coef;
int exp;
struct Node*next;
}
8.
(1)
struct*Node
{
int data;
struct Node*next;
}
(2)
i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→NULL
(3)
5
3
2
1
1.
回覆刪除int gcd ( int x , int y )
{
int r = x % y ;
if ( r = = 0 )
return y ;
else
return gcd ( y , r ) ;
}
gcd ( 55 , 121 ) = 11
5 55 121 2
55 110
0 115
11
Ans:11
2.
(2)i=n;
do{ a-=3;
i/=3;
}while(a>0);
Ans: O(n)
5. (1)sizeof(x)=4+30+4=38→40
(2)輸出noname
50
7. (1)stuct Node
int coef;
int exp;
struct Node*next;
8. (2) i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→NULL
(3) 5
3
2
1
9. (1)插入中間節點:
newnode→next=ptr→next;
ptr→next=newnode;
(2)刪除中間節點
while(current→next!=ptr)
current→next=ptr→next;
current=ptr→next;
1.int gcd(int x,int y)
回覆刪除{int r=x%y;
if (r==0)return y;
else return gcd(y,r);
}
5│55│121│2
│55│110│
├─ ┼── ┤
│ 0│ 11│
2. (2) 0(n)
3.記憶體 位置 名稱 型態
301 0x0012FF7C i int
50 0x0012FF78 j int
0x0012FF78 0x0012FF74 ptr *int
0x0012FF7C 0x0012FF70 ptr1 *int
* ptr = 50 * ptr1 = 301
5.
(1)
4+30+4=38→40
(2)
noname
50
7.
(1)Node之定義:
struct Node
{
int coef;
int exp;
struct Node* next;
};
8.
(2)
i 0 1 2 3 4
k=(i+4)%len 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→NULL
(3)輸出
5
3
2
1
9.
刪除中間節點
while (current → next != ptr)
current = current → next;
cuttent → next = ptr → next;
2.
回覆刪除O(nlogn),O(n),O(logn)
5.
(1)sizeof(x)=4+30+4=38→40
(2)輸出noname,50
7.
(1)stuct Node
int coef;
int exp;
struct Node*next;
8.
(2)
i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→NULL
(3)
5
3
2
1
9.
(2)刪除中間節點
while(current→next!=ptr)
current→next=ptr→next;
current=ptr→next;
1.
回覆刪除int gcd(int x,int y)
{int r=x%y;
if (r==0)return y;
else return gcd(y,r);
}
5│55│121│2
│55│110│
├─┼─-┤
│ 0│ 11│
2.
(2) 0(n)
3.記憶體 位置 名稱 型態
301 0x0012FF7C i int
50 0x0012FF78 j int
0x0012FF78 0x0012FF74 ptr *int
0x0012FF7C 0x0012FF70 ptr1 *int
* ptr = 50 * ptr1 = 301
6.
row col value
0 0 7
0 8 3
3 3 3
4 0 7
5.
(2)noname
50
7.
(1)
sturuct Node{
int coef;
int exp;
sturuct Node*next;
}
(3)
所有節點都是中間節點
8.
(2)
i 0 1 2 3 4
k=(i+4)%len 4 0 1 2 3
array[k] 8 1 2 3 5
first→5→3→2→1→8→NULL
(3)輸出
5
3
2
1
9.
插入中間節點
newnod->next=ptr->next;
ptr->next=newnode;
刪除中間節點
while (current → next != ptr)
current = current → next;
cuttent → next = ptr → next;
1.int gcd(int x,int y)
回覆刪除{int r=x%y;
if (r==0)return y;
else return gcd(y,r);
}
算式:
5│55│121│2
│55│110│
├─┼──┤
│ 0│ 11│
5.(1)
4+30+4=38→40
(2)
noname
50
7.(1)
sturuct Node{
int coef;
int exp;
sturuct Node*next;
}
8.(1)
struct Node{
int date;
struct Node*next;
}
(2)
First→5→3→2→1→8→NULL
(3)
5
3
2
1
1. gcd(55,121)=11
回覆刪除5 55 121 2
55 110
0 115
11
3.
記憶體 位置 名稱 型態
301 0x0012FF7C i int
50 0x0012FF78 j int
0x0012FF78 0x0012FF74 ptr int*
0x0012FF7C 0x0012FF70 ptr1 int*
*ptr=50 ptr1=301
5.(2)
noname
50
6. row col value
0 0 7
0 8 3
3 3 3
0 4 7
7. (1)struct Node{
int coef;
int exp;
struct Node*next;
}
(3)所有節點都是中間節點
8.(2)
i 0 1 2 3 4
k=(i+4)%5 4 0 1 2 3
array[k] 8 1 2 3 5
first->5->3->2->1->8->NULL
8.(3)
5
3
2
1