Đề bài: Viết chương trình khởi tạo danh sách các số nguyên, in ra màn hình các số chẵn và đếm có bao nhiêu nút. Mã: #include <stdio.h> #include <conio.h> typedef int Elementype; typedef struct SN{ Elementype a; SN *next; }; SN *L; void Nhap(SN *&L) { SN *C,*P; int x; char ch; C=NULL; do { P=new SN; printf("\nNhap gia tri: "); scanf("%d",&x); P->a=x; P->next=NULL; if (L==NULL) { L=P; C=P; } else { C->next=P; C=P; } printf("\nDung lai = y? "); scanf("%s",&ch); } while (ch!='y'); } void Xuat(SN *L) { SN *P; P=L; while (P!=NULL) { printf("\t%d",P->a); P=P->next; } } void Sochan(SN *L) { SN *P; P=L; printf("\nCac so chan: "); while (P!=NULL) { if (P->a%2==0) printf("\t%d",P->a); P=P->next; } } int Dem(SN *L) { int dem=0; SN *P; P=L; while(P!=NULL) { dem=dem+1; P=P->next; } printf("\nSo nut la: %d",dem); } main() { clrscr(); int k,x,a; L=NULL; Nhap(L); printf("\nDVSVT: "); Xuat(L); Sochan(L); Dem(L); getch(); return 1; } File đính kèm (đổi đuôi .TXT thành .CPP nhé):