Programming C: Posts 13 – List installed applications associated with the cursor
Content
- 1. Install list
- 2 Initialize empty list
- 3 Check the list is empty or not
- 4 Calculate the length of the list
- 5 Create 1 Node list
- 6 Insert Node P in the first place
- 7. Insert Node P at position k in list
- 8 Find the value of x elements contained in the list
- 9 Remove element in the first place
- 10. Clear quarters in position k
- 11. Remove element value x
- 12. Complete program (full)
List of links can be installed in arrays or pointers. In this article I will guide you to use the cursor :), Type this list referred to as single-linked list
In the previous post I wrote code are all standard C, but from now on I will interspersed bit of C structures in this article you should code to the file * .cpp offline.
List of links can be described as follows:
Data is data in which each node, Students may be, worker,… (item type, and I do simple integer), Next is a pointer to the next element.
[qads]
1. Install list
typedef int item; //kieu cac phan tu dinh nghia la item typedef struct Node //Xay dung mot Node trong danh sach { item Data; //Du lieu co kieu item Node *next; //Truong next la con tro, tro den 1 Node tiep theo }; typedef Node *List; //List la mot danh sach cac Node
2 Initialize empty list
void Init (List &L) // &L lay dia chi cua danh sach ngay khi truyen vao ham { L=NULL; //Cho L tro den NULL }
In the previous post that can change the value of the function for which we pass on we will often use pointer variables (*) and the function call we need & before the turn however when we use the address as soon as the transfer function is initialized in the first function call our normal operating variable transmission without taking address (more &) before turning again.
(This is a television address to the variable in the function in C .)
3 Check the list is empty or not
This explains a lot from:
int Isempty (List L) { return (L==NULL); }
4 Calculate the length of the list
We use 1 Node to navigate from start to finish, browse Count
int len (List L) { Node *P=L; //tao 1 Node P de duyet danh sach L int i=0; //bien dem while (P!=NULL) //trong khi P chua tro den NULL (cuoi danh sach thi lam) { i++; //tang bien dem P=P->next; //cho P tro den Node tiep theo } return i; //tra lai so Node cua l }
5 Create 1 Node list
Creating 1 Node information contained in the list makes it easy to insert, delete and manage lists more. First, we will have to allocate memory for Data Node and then assigned to be ok
Node *Make_Node (Node *P, item x) //tao 1 Node P chua thong tin la x { P = (Node *) malloc (sizeof (Node)); //Cap phat vung nho cho P P->next = NULL; //Cho truong Next tro den NULL P->Data = x; //Ghi du lieu vao Data return P; }
6 Insert Node P in the first place
To insert P on the top of the list for our first point P to L, then only for the L point of P is ok
void Insert_first (List &L, item x) //Chen x vao vi tri dau tien trong danh sach { Node *P; P = Make_Node(P,x); //tao 1 Node P P->next = L; //Cho P tro den L L = P; //L tro ve P }
7. Insert Node P at position k in list
First, we check the insertion position is valid, If a valid test to insert into place 1 There k> 1 . For k> 1 we perform Node Q browse by location k-1 then the P-> Q- Next pointer to Node> Next, Next to the Q-> Next point to P
void Insert_k (List &L, item x, int k) //chen x vao vi tri k trong danh sach { Node *P, *Q = L; int i=1; if (k<1 || k> len(L)+1) printf("Vi tri chen khong hop le !"); //kiem tra dieu kien else { P = Make_Node(P,x); //tao 1 Node P if (k == 1) Insert_first(L,x); //chen vao vi tri dau tien else //chen vao k != 1 { while (Q != NULL && i != k-1) //duyet den vi tri k-1 { i++; Q = Q->next; } P->next = Q->next; Q->next = P; } } }
8 Find the value of x elements contained in the list
I browse the list until found or the end and returns the position if found, otherwise it returns 0
int Search (List L, item x) //tim x trong danh sach { Node *P=L; int i=1; while (P != NULL && P->Data != x) //duyet danh sach den khi tim thay hoac ket thuc danh sach { P = P->next; i++; } if (P != NULL) return i; //tra ve vi tri tim thay else return 0; //khong tim thay }
9 Remove element in the first place
First, we store the value of the first element to the variable x, Then proceed to the point L to L> Next
void Del_frist (List &L, item &x) //Xoa phan tu dau tien { x = L->Data; //lay gia tri ra neu can dung L = L->next; //Cho L tro den Node thu 2 trong danh sach }
10. Clear quarters in position k
Use the browse to the location P k-1 and proceed to P-> Next point to the next quarter ignoring k k. Note in Figure forget to save your value to be deleted but you should save it as deleted in the first place.
void Del_k (List &L, item &x, int k) //Xoa Node k trong danh sach { Node *P=L; int i=1; if (k<1 || k>len(L)) printf("Vi tri xoa khong hop le !"); //kiem tra dieu kien else { if (k==1) Del_frist(L,x); //xoa vi tri dau tien else //xoa vi tri k != 1 { while (P != NULL && i != k-1) //duyet den vi tri k-1 { P=P->next; i++; } P->next = P->next->next; //cho P tro sang Node ke tiep vi tri k } } }
11. Remove element value x
Simply put, we find x in the list by Search and delete functions in the position to find that we get
void Del_x (List &L, item x) //xoa phan tu x trong danh sach { while (Search(L,x)) Del_k (L,x,Search(L,x)); //trong khi van tim thay x thi van xoa }
12. Complete program (full)
#include<stdio.h> #include<stdlib.h> typedef int item; //kieu cac phan tu dinh nghia la item typedef struct Node //Xay dung mot Node trong danh sach { item Data; //Du lieu co kieu item Node *next; //Truong next la con tro, tro den 1 Node tiep theo }; typedef Node *List; //List la mot danh sach cac Node void Init (List &L); //khoi tao danh sach rong int len (List L); // Do dai danh sach Node *Make_Node (Node *P, item x); //Tao 1 Node P voi thong tin chu trong no void Insert_first (List &L, item x); //Chen phan tu vao dau danh sach void Insert_k (List &L, item x, int k); //Chen phan tu vao vi tri k trong danh sach void Input (List &L);//Nhap danh sach void Output (List L);//Xuat danh sach int Search (List L, item x); //Tim phan tu x trong danh sach, ham tre ve vi tri cua phan tu tim duoc void Del_frist (List &L, item &x); //Xoa phan tu dau danh sach void Del_k (List &L, item &x, int k); //Xoa phan tu vi tri k trong danh sach void Del_x (List &L, item x);//Xoa phan tu co gia tri x trong danh sach void Init (List &L) // &L lay dia chi cua danh sach ngay khi truyen vao ham { L=NULL; //Cho L tro den NULL } int Isempty (List L) { return (L==NULL); } int len (List L) { Node *P=L; //tao 1 Node P de duyet danh sach L int i=0; //bien dem while (P!=NULL) //trong khi P chua tro den NULL (cuoi danh sach thi lam) { i++; //tang bien dem P=P->next; //cho P tro den Node tiep theo } return i; //tra lai so Node cua l } Node *Make_Node (Node *P, item x) //tao 1 Node P chua thong tin la x { P = (Node *) malloc (sizeof (Node)); //Cap phat vung nho cho P P->next = NULL; //Cho truong Next tro den NULL P->Data = x; //Ghi du lieu vao Data return P; } void Insert_first (List &L, item x) //Chen x vao vi tri dau tien trong danh sach { Node *P; P = Make_Node(P,x); //tao 1 Node P P->next = L; //Cho P tro den L L = P; //L tro ve P } void Insert_k (List &L, item x, int k) //chen x vao vi tri k trong danh sach { Node *P, *Q = L; int i=1; if (k<1 || k> len(L)+1) printf("Vi tri chen khong hop le !"); //kiem tra dieu kien else { P = Make_Node(P,x); //tao 1 Node P if (k == 1) Insert_first(L,x); //chen vao vi tri dau tien else //chen vao k != 1 { while (Q != NULL && i != k-1) //duyet den vi tri k-1 { i++; Q = Q->next; } P->next = Q->next; Q->next = P; } } } int Search (List L, item x) //tim x trong danh sach { Node *P=L; int i=1; while (P != NULL && P->Data != x) //duyet danh sach den khi tim thay hoac ket thuc danh sach { P = P->next; i++; } if (P != NULL) return i; //tra ve vi tri tim thay else return 0; //khong tim thay } void Del_frist (List &L, item &x) //Xoa phan tu dau tien { x = L->Data; //lay gia tri ra neu can dung L = L->next; //Cho L tro den Node thu 2 trong danh sach } void Del_k (List &L, item &x, int k) //Xoa Node k trong danh sach { Node *P=L; int i=1; if (k<1 || k>len(L)) printf("Vi tri xoa khong hop le !"); //kiem tra dieu kien else { if (k==1) Del_frist(L,x); //xoa vi tri dau tien else //xoa vi tri k != 1 { while (P != NULL && i != k-1) //duyet den vi tri k-1 { P=P->next; i++; } P->next = P->next->next; //cho P tro sang Node ke tiep vi tri k } } } void Del_x (List &L, item x) //xoa phan tu x trong danh sach { while (Search(L,x)) Del_k (L,x,Search(L,x)); //trong khi van tim thay x thi van xoa } void Input (List &L) //nhap danh sach { int i=0; item x; do { i++; printf ("Nhap phan tu thu %d : ",i); scanf("%d",&x); if (x != 0) Insert_k(L,x,len(L)+1); } while(x != 0); //nhap 0 de ket thuc } void Output (List L) //xuat danh sach { Node *P=L; while (P != NULL) { printf("%5d",P->Data); P = P->next; } printf("\n"); } int main() { List L; Init(L); Input(L); Output(L); int lua_chon; printf("Moi ban chon phep toan voi DS LKD:"); printf("\n1: Kiem tra DS rong"); printf("\n2: Do dai DS"); printf("\n3: Chen phan tu x vao vi tri k trong DS"); printf("\n4: Tim mot phan tu trong DS"); printf("\n5: Xoa phan tu tai vi tri k"); printf("\n6: XOa phan tu x trong DS"); printf("\n7: Thoat"); do { printf("\nBan chon: "); scanf("%d",&lua_chon); switch (lua_chon) { case 1: { if (Isempty(L)) printf("DS rong !"); else printf ("DS khong rong !"); break; } case 2: printf ("Do dai DS la: %d.",len(L));break; case 3: { item x; int k; printf ("Nhap phan tu can chen vao DS: "); scanf("%d",&x); printf ("Nhap vi tri can chen: "); scanf ("%d",&k); Insert_k (L,x,k); printf ("DS sau khi chen:\n"); Output(L); break; } case 4: { item x; printf ("Moi ban nhap vao phan tu can tim: "); scanf("%d",&x); int k=Search(L,x); if (k) printf ("Tim thay %d trong DS tai vi tri thu: %d",x,k); else printf ("Khong tim thay %d trong danh sach !",x); break; } case 5: { int k; item x; printf ("Nhap vi tri can xoa: "); scanf ("%d",&k); Del_k (L,x,k); printf ("DS sau khi xoa:\n"); Output(L); break; } case 6: { item x; printf ("Nhap phan tu can xoa: "); scanf ("%d",&x); Del_x (L,x); printf ("DS sau khi xoa:\n"); Output(L); break; } case 7: break; } }while (lua_chon !=7); return 0; }
[rps-include post=”2703″ shortcodes=”false”]
Hi host, bai viet rat chi tiet va ti mi. Thanks host spent time de share with everyone.
Ming contained a question: void Init (List &The) Looks like C without operators & the parameters passed in 1 function, This method uses only the C . Nho host check lai gium 🙂
If I wanted to use the structure of the C implementation on like this intelligent comic (List *L) right host?
Yeah you. 🙂
Bài này làm sao a Quân
Cho một danh sách liên kết đơn có nút đầu danh sách trỏ bởi p. Giá trị của trường INFO trong các nút giả sử là các số khác nhau và các nút đã được sắp xếp theo thứ tự tăng dần của giá trị này. Hãy viết hàm để thực hiện:
– Bổ sung một nút mới mà trường INFO có giá trị là X, vào danh sách.
– Loại bỏ một nút mà trường INFO có giá trị bằng K cho trước.
Welcome, Thank you for encouraging. At the beginning I had told you that: “In the previous post I wrote code are all standard C, but from now on I will interspersed bit of C structures in this article you should code to the file * .cpp offline”
My friend asked a tẹo yourself alone, not related to exercise, but how to get the environment editor c code these dear?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
void Insert_k (List &The, item x, int k) //chen k x into place in the list
{
Node *P, *Q = L;
int i=1;
if (the only(The)+1) printf(“Vi tri chen khong hop le !”); //kiem tra dieu kien
else
{
P = Make_Node(P,x); //man 1 Node P
if (k == 1) Insert_first(The,x); //chen vao vi tri dau tien
else //chen vao k != 1
{
while (Q != NULL && in != k-1) //duyet den vi tri k-1
{
i ;
Q = Q->next;
}
P->next = Q->next;
Q->next = P;
}
}
}
The number 1,2,3,4,5,6… ý bạn ạ 🙂 Cảm ơn bạn nhá
Did you ask the editor on your computer or write on the web?
If your computer is sought (search google) according to what you are used to display the line number. VD display line numbers in dev-C.
If you are on the web then you see the display plugin code nhé, I used the example wordpress SyntaxHighlighter, you see here:
https://www.cachhoc.net/2014/06/18/wordpess-hien-thi-code-tren-wordpress-voi-syntax-highlighted-posting-source-code-on-wordpress-with-syntax-highlighted/
This. I want to save the .c extension to rewrite Learning , but it does not run dc . Now want to move all in from his exam .c .cpp to do ntn . huhu
Then you switch from reference types in C to C pointer type is to be.
I wonder in the delete function node did not release the memory of (the) That node. Such wasteful correct his memory? Thank you.
Yeah you. Thank you for feedback. I'll quickly corrected.
Hello, theo như bạn Hoàng Duy đã nói phía trên, thì mh k giải phóng thì gây lãng phí, nhưng e có thắc mắc là mh khai báo cái Node đó trong hàm, vậy nó là biến cục bộ, khi thoát hàm nó sẽ biến mất… không biết ý e như v có đúng k nữa. mong anh giải thích thêm. e thank you. :))
Ah về cái này cần xem biến đó khai báo theo con trỏ hay ko. Vd Note *P là con trỏ thì ko mất.
He asked the site created 1 leaving the node *, *Make_Node reviews ạ
Execution function returns 1 structure pointer – ie 1 Node you.
hi a, a giúp e được k ạ
the) Tạo một ngăn xếp bằng danh sách liên kết gồm các số tự nhiên ( số phần
tử do người dùng nhập vào)
b) Đếm xem trong trong ngăn xếp có bao nhiêu phần tử thỏa mãn điều kiện
chia hết cho 3
I salute Nguyen Van Quan. I'm having a bit of trouble when doing assignments. Hope you answer giùm!!! Inquiry problem was calculated with the operations on polynomials over integer. you must write code to read a function definition file input and ADD operations ,SUB, MUD, DIV, MOD.
performs the operation order from left to right not distinguish this invovled use math expression structure contains polynomial, polynomial contains unimodal and linked lists.
example:input.txt:
1 3 6 2 -3 0 ///x^3 6*x^2-3
ADD
6 2 -7 1 4 0 ///6*x^2-7*x 4
DIV
1 2 -1 1 ///x^2-x
the output is:
1 1 13 0 ////x 13
(the execution order is the addition ADD operations before, DIV sau). read file line by line if the variable int k = 0 turn from the first run files coefficient k odd is unimodal, even as the exponent k unimodal. so how to connect applications together and form it in polynomial?!?
I look forward to receiving your answer!!!
I thank you very much!!!
Installing this type involves the expression tree, but regret and apologize to his current should not learn about it can not help anything for you.
yes,
thank you !
Waiter,you can add entries to the tree,search algorithms and graph are not ạ?
Fennel has a number of items here: https://www.cachhoc.net/category/thuat-toan/cay/
The graph also some: https://www.cachhoc.net/category/thuat-toan/do-thi/
Còn tìm kiếm thì chưa có sao ý, sẽ cố gắng viết 😉
Anh Quân cho em hỏi là tại sao có lỗi
Error 2 error C4700: uninitialized local variable ‘P’ used
này ạ, em giải phòng rồi nhưng vẫn không chạy được. Em cảm ơn a.
Nó báo là biến P chưa được khởi tạo bạn ah.
giải quyết cái này bằng cách nào vậy bạn?
cho mình hỏi làm sao để nhận biết nên dùng danh sách liên kết hay danh sách đặc trong khi đề bài không nói rõ ah?
Often mentioned but the assignment would otherwise depending on the characteristics of the type of data and manipulating. For example, the data is not fixed and can be added or removed at any time, use a linked list and vice versa.
Can I ask you a question, if you build some content such dslk then and if you want to use another structure which they do not want to rewrite the code, you can define it in Node structure is not? if it is then defined ntn??? =]]
Well you ah, You just need to change the type of item (themselves to be int) the other type (float, struct…) is finished (ah, they do not have to write separate import and export functions, you also need to write more for your type nhé)
– ask yourself is all on the jaw Insert_k, Review site conditions, why is “to>only(The)+1” so ?
CEO: have 3 the function element under wool, the wool = 3, I think the k follow>3 dc, why is k>3+1?
– Articles of a very rewarding, thanks a shared.
Because the position is 1,2,3 so you can insert into place 1,2,3,4 but if only> k, are not there 4 (Last ds)
Oh, thanks
His article is very detailed. Thank you very much
Thank you. Please share it to your friends offline
His so-Output Waiter it was wrong. I tested on VS 2015 it does not come out right results.
Dev-C code yourself on this may be another you ah.
So it may want its output so how now he ? I have tried to correct some persons, but it was not the result.
This alone is unknown because no user vs.
Several doctors to write this article by pascal DC wrote to e k e r examinee
🙁
Phunghoang070393@gmail.com dental care provider
A for e chut.bay now I want to ask to use arrays for respondents, how DSLK ạ?
You see all 12 home.
strcmp(x,” “) nghĩa là sao vậy anh !!
Ie comparing x vs spaces.
e asked me a run on the code block is that it does not stop the introduction element where the error ạ. keep running forever enter secondary element …
You see what is stopping criterion is based on that alone
asked me why sometimes above used ” List” sometimes used “NODE* ” . 2 What's different this not ?
List is himself alluded 1 list, NODE * himself alluded 1 NODE pointer type. Although it essentially the same but how we use your due naod.
Like * a, *b. We can use such a 1 Plate 1 evening, while b is pointer int.
British Army I wanted oi enter eg the name list how they ạ?
You redefine the struct item is not int is đk.
Let me ask the right part 8. In conditions established while there is p != NULL, while the island so you can do while on the condition of p->next != NULL, because no data input is not empty list.
No part of his talk is not empty ds should you need to consider carefully. And if your code is still guaranteed đk as you say
I do not know where to find valuable element x ạ?
You do not understand how…
Let me ask at the 7 , after performing his then pointer L will be shifted so he could create a | node * q = L; after making his return to insert the L = q is not?
You can if you want
let me ask why he gave Make_node jaw P->Next = Null then where he remained for the function Insert node P->Next= L ( where L = NULL) so he? 2 this place so different
L is my list that. Where it has null you?
Da yes sir e e get it there 1 more questions in wrote as a function Insert_k :
while (Q != NULL && in != k-1) //duyet den vi tri k-1
{
i ;
Q = Q->next;
}
P->next = Q->next;
Q->next = P;
ie until approval Q-> next = null ms thôi, fat->make_node jaw, the next available = NULL then you can remove the line P->next=Q-> next and the Q->DC next = P are not a?
my. You also shrugged Technical conditions i!= K-1 again. Q-> Other unlikely next null
Let me ask why 2 remove content (part 9,10) delete command does not always. According em understand, 2 That part just remove the node from the list only, but that node still exists in memory (because the pointer type)?
Delete command is the command you.
e think he would want his memory release, as there 1 top you can contribute. :))
e asked why by the way for this to run on e copy source vs 10 the right time to re-enter k DC, its error: “The variable ‘P’ is being used without being initialized.” Apparently due to an uninitialized value, but in the post of a dual dslk then k is s… I k is s more info :(( confusion too. expect a review to try giùm e, thank you :]]
I'm not used to not clear why vs again.
Hello, a nice article but e co a question thavs is in initialization list is empty, l is then reproduced pointer reference used to do sir ,e thank you sir
So when you get out, the L function can be changed. If not used the reference is in the function to use L = null
e still do not understand lam a, when enforcement clever pass a pointer out of the tunnel when no valve can change a dc khong dung?
But this is his Ukn pointer cursor
yeah e thank sir
Let me ask at the 5, create 1 the operator node * Previous work function name, what was?.
Thank you in advance
It means returns 1 pointer
Friend. Cho mình hỏi chút. I had broken apart in your code. Specifically, his separation empty list, when finished entering the elements and enter 0 to finish, but it does not print out the elements entered. So want to print the imported element is how you. thank you
I have not quite understand what you mean. Above the split himself also functions such that
My friends,Can I ask you a question,stars show themselves not so fast,hi
You can send your bug ko?
when you run your program, it shows up as:Import element 1, then enter your finished program element enter the 2nd call, so just hung,do not stop,you help yourself dentist,hi
You see the stop condition offline. Until the entry of 0 then stop.
Let me ask the [Warning] ‘typedef’ was ignored in this declaration [enable by default]. Having affect programs that not a ?
Why is it that when we allocate memory for P it cannot be used and give an error, if we put it in Insert_first and Insert_k then ok?
CEO: Node *Make_Node (Node *P, item x) //man 1 Node P has no information as x
{
P = (Node *) malloc (sizeof (Node)); //Cap splashed grapes for P
P->next = NULL; //Let Next field go to NULL
P->Data = x; //Ghi du lieu vao Data
return P;
}
void Insert_first (List &The, item x) //Chen X on the first position in the list
{
Node *P;
P = Make_Node(P,x); //man 1 Node P
P->next = L; //P pointing to L
L = P; //L tro ve P
}
void Insert_k (List &The, item x, int k) //chen k x into place in the list
{
Node *P, *Q = L;
int i=1;
if (the only(The)+1) printf(“Vi tri chen khong hop le !”); //kiem tra dieu kien
else
{
P = Make_Node(P,x); //man 1 Node P
if (k == 1) Insert_first(The,x); //chen vao vi tri dau tien
else //chen vao k != 1
{
while (Q != NULL && in != k-1) //duyet den vi tri k-1
{
i ;
Q = Q->next;
}
P->next = Q->next;
Q->next = P;
}
}
}——-> Will not run !
even if:
void Insert_first (List &The, item x) //Chen X on the first position in the list
{
Node *P;
P = (Node *) malloc (sizeof (Node)); //Cap splashed grapes for P
P->next = NULL; //Let Next field go to NULL
P->Data = x; //Ghi du lieu vao Data
P->next = L; //P pointing to L
L = P; //L tro ve P
}
void Insert_k (List &The, item x, int k) //chen k x into place in the list
{
Node *P, *Q = L;
int i=1;
if (the only(The)+1) printf(“Vi tri chen khong hop le !”); //kiem tra dieu kien
else
{
P = (Node *) malloc (sizeof (Node)); //Cap splashed grapes for P
P->next = NULL; //Let Next field go to NULL
P->Data = x; //Ghi du lieu vao Data
if (k == 1) Insert_first(The,x); //chen vao vi tri dau tien
else //chen vao k != 1
{
while (Q != NULL && in != k-1) //duyet den vi tri k-1
{
i ;
Q = Q->next;
}
P->next = Q->next;
Q->next = P;
}
}
}————>ok then run
England forward please explain.
thanks you !
Of, I understand your ideas, however its not clear where errors, may be due to syntax error code you can by making errors. Should not you explain.
Data declaration part, why not for always : int Data hả a ?!!
To his later change the data type flexibility
if the item is a data type struct, the maxillary change how ạ? especially the search function a
he has all of the linked list of pascal k?
Apparently not :3
I do not understand very much a function check hollow he could explain it to you is not it ?
L == NULL comparison will return true (1) became (0). Therefore it contains values and one can always return it always.
Sorry, but you do have bugs and wrong ~~
Thank you, you please let us know where the error is and how is not. I will correct the errors if true. 🙂
I do not hỉu site data entry list to help explain a ko e dk
I thank
Enter your data is entered, the value for list of severance
Looks like part 1 current 7 problem:
typedef Node *List;
If written as on the entire structure will be defined as node type “*List”, sign * this time will only act as a character string “*List”. So to bring the whole string “*List” go to define other elements.
//If false, then expect sympathy :))
Oil * That means that the pointer rather than the light chain.
He annotated L = NULL is to point to NULL L;
// So why in the address of L printf(“%d”,The); it came out 0(NULL) sir ? So NULL is the address of L, or where it points to. :/
which offered him, write pure C C, C ++, but do not pull on the combination without annotations, I was pressing a little that's right
I have said in the article are from all 13 I would code for a simple and a bit of that.
Waiter allocates memory space you use malloc, they are written in C #, I know some function for malloc ko sir replacement ?
you can use calloc see stars. that C # does not need malloc or calloc then eh?
yourself questions in the settings list in mind if written in standard C code they write ntn sir? I am studying in standard c lt should only written in c ++ k DC .Mong he fears his troops to write code for
Write the standard C functions without & that used * to indicate it is a pointer. When calling the function, use &.
VD build permutation function
void hoanVi(int *a, int *b)
…
call function: hoanVi(&x, &and);
A misinterpreted his troops r. I wanted to ask in the first part reviews, When installing ds, then write code c type g. Because when I copy all and run on devc, it fails at the command typedef node * list. a quân có sửa đc lỗi này khi chạy trên c đc k
Muốn sửa mình cần biết nó báo lỗi gì mới sửa được 🙂
Ad ơi k có code cho mấy cái hàm trao đổi hay sẵp xếp node à ad?
Ah phần đó không có nhé.
Anh cho em hỏi đoạn code này
typedef struct // Build a Node node in the list
{
item Data; //Styled data item
Node *next; //Truong with the next tro, believe it 1 Next node
};
This paragraph if the C language code(file.c) will error “What is not said in paragraph Node Next Node * ”
Also in C ++(file.cpp) the normal run is not it sir ? He can only fix them how to be able to run on C dc ko ?
In C, you add struct before nhé.
struct Node *next;
Thank you !
Rất tuyệt vời! Thank you very much
However, có cách nào xóa trực tiếp một phần tử có giá trị x mà không cần gọi đệ quy như cách anh giới thiệu không?
Không e nhé. Hoặc đến thời điểm này thì mình không biết 🙂
anh ơi trong các hàm trên hàm liên quan đến giá trị x tại sao có hàm dùng int &x, có hàm là int x vậy ạ. Khi nào thì dùng kiêu tham chiếu & sir??
Khi muốn giữ lại giá trị của x sau khi ra khỏi hàm nhé.
I asked him for some of the parts ordered by his code with sir!. I have tried but not succeeded, I refer to the code used mostly pointer to the head and tail, applies to all brothers do not know how to write such, look forward to his help!. Thanks you very much!
I just consider it a standard array. Plate should a[in] and a[j] to compare, swapped. But here they make it 2 pointers p and q corresponds to a[in], the[j]. The e swapped the cut and pointing to the appropriate link is.
yourself asking is if the input function 0 Thus it would stop now if you want to enter 0 on, why sir?
Then you 1 Other conditions. VD input 1 negative number then stop…
Hello,
He asked me why in the constructor of a button (Node *Make_Node) he used to declare function pointer type? The declaration so what purpose? And can write the function like a normal function PES?
Wanting function returns 1 cursor should write such. Like lust returns an int type, the raw ham() so.
My ad for you to ask you to do 1 c program requirements are entered 1 text files and output to all the characters of the file with the location of the file in the text , which letters overlap, just given how much current position and ranked some of that line ..
I asked for a military application linked list single and dual link list ạ. e show single stack used by DSLK, also commonly used queue dual DSLK. If using easy access queue so why have to use the stack sir. Thanks a!
Because queue and stack the different applications.
Anh Quân cho em hỏi ạ
Section inserts element x into position k, His military code just divide 2 case: inserted between, insert the top of the list
But the student learn, as in document PTIT, they divided 3 case: first insert, inserted between, insert the end of the list
So how should he Quan ?
How well have too.
Evening e salute a. E are a little on this troubled. E did but it only outputs DC 1 student . Other verses remaining k run DC. A desire to help e.
Use linked list structure to define menu 1 store list 1 list of students.
Information sv include student ID, threats, Diem , XLoai
The) Useful import function 1 dssv from keyboard
B) print screen function wrote dssv
C) Useful search function 1 sv have student ID number entered from the keyboard DC. If found return the address of that node. Otherwise it returns the NULL
D) write jaw removed from DS 1 sv have student ID number entered from the keyboard DC
And) Useful additional functions 1 sv following new elements return address in the D
F) Useful additional functions 1 New to the previous sv elements return address in the D
G) create 1 menu allows the selection of work on the implementation of COG
Hello! He e asked about his top code with.
1. Initialize the list L = NULL
– Asked why not assign L->next = NULL which is L = NULL.
2. Insert node P at the beginning of the list L, assuming L = NULL
– Asked this time P is pointing to NULL or P->Next point to NULL.
Thank you.
1. L is a list, the list must be used to initialize L = null instead, L-> next = NULL is the next element to NULL gone longer where.
2. P-> next to NULL pointer nhé, Since P is worth it.
Hello, a presentation for e can not you do this is up to this stage, I squash:
Said students have the lowest average score of the students rated excellent.
I thank
I find those students who have points> X is the smallest but was OK with him. X is to classify solid.
Write the function to calculate the number of nodes of the linked list using recursive method
Let me ask why there are single link lists,double ,ring
Each one it aimed at 1 different purposes. You can go online for more reference