<?xml version="1.0"?>
<rss version="2.0">
   <channel>
      <title>BÀI TẬP NHÓM 8 by Ngô Thị Phương Nhung</title>
      <link>https://padlet.com/22115053122235/t0b1grggqqve9c25</link>
      <description></description>
      <language>en-us</language>
      <pubDate>2024-01-01 08:08:58 UTC</pubDate>
      <lastBuildDate>2024-01-08 08:48:21 UTC</lastBuildDate>
      <webMaster>hello@padlet.com</webMaster>
      <image>
         <url></url>
      </image>
      <item>
         <title>1. Tìm kiếm chuỗi (Nguyễn Ngọc Tú Anh)</title>
         <author>22115053122235</author>
         <link>https://padlet.com/22115053122235/t0b1grggqqve9c25/wish/2836224475</link>
         <description><![CDATA[<p>Input: chuỗi (n), chuỗi(x)</p><p>Output: x có trong n hay không, số lần xuất hiện của x trong n</p><p>&nbsp;</p><p>Mô tả thuật toán:</p><p>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Lần lượt đi từ đầu chuỗi đến cuối chuỗi.</p><p>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Trong quá trình đi, nếu phát hiện ký tự đầu tiên giống nhau thì lần lượt so sánh xem liệu n[i+1] và x[j+1] có giống nhau hay không, với điều kiện chuỗi n khác NULL.</p><p>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Nếu dãy ký tự x có độ dài bằng chuỗi n thì biến đếm số lần xuất hiện cộng 1.</p><p>&nbsp;</p><p>Cài đặt thuật toán:</p><p>&nbsp;</p><p>#include&lt;stdio.h&gt;</p><p>#include&lt;string.h&gt;</p><p>&nbsp;</p><p>void taoChuoi(char n[], char x[]){</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf ("Nhap chuoi: ");</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fflush(stdin);</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gets(n);</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf ("Nhap chuoi can tim: ");</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gets(x);</p><p>}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p><p>&nbsp;</p><p>int search(char n[], char x[]) {</p><p>&nbsp;&nbsp;&nbsp; int i, j, dem;</p><p>&nbsp;&nbsp;&nbsp; dem = 0;</p><p>&nbsp;&nbsp;&nbsp; for (i = 0; n[i] != NULL; i++) {</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; j = 0;</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (n[i] == x[j]) {</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (n[i] == x[j] &amp;&amp; n[i] != NULL) {</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i++;</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; j++;</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (x[j]  NULL &amp;&amp; (n[i]  ' ' || n[i] == NULL))</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dem++;</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i--;</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p><p>&nbsp;&nbsp;&nbsp; }</p><p>&nbsp;&nbsp;&nbsp; return dem;</p><p>}</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p><p>main(){</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char n[255], x[255];</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; taoChuoi(n,x);</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(search(n,x)&gt;0)</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf ("\nChuoi %s xuat hien %d lan.", x, search(n,x));</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf ("\nChuoi %s khong xuat hien.");</p><p>}</p>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/2273703694/39df2efa3c77816b0cad84ed64c8ce1c/image.png" />
         <pubDate>2024-01-01 08:18:35 UTC</pubDate>
         <guid>https://padlet.com/22115053122235/t0b1grggqqve9c25/wish/2836224475</guid>
      </item>
      <item>
         <title>2. Đối sánh chuỗi (Ngô Thị Phương Nhung)</title>
         <author>22115053122235</author>
         <link>https://padlet.com/22115053122235/t0b1grggqqve9c25/wish/2836224511</link>
         <description><![CDATA[<p>input: chuỗi con(n),chuỗi mẹ(m)</p><p>với m n lần lượt là độ dài 2 chuỗi</p><p>Output: vị trí xuất hiện (Nếu chuỗi con xuất hiện trong chuỗi mẹ) hoặc 1(Nếu chuỗi con không xuất hiện trong chuỗi mẹ)</p><p><br/></p><p><br/></p><p>Mô tả thuật toán</p><ol><li><p>Xây dựng mảng để lưu trữ thông tin</p></li><li><p>Bắt đầu tìm kiếm mẫu trong chuỗi bằng cách duyệt từ trái sang phải. So sánh các ký tự của chuỗi và mẫu tương ứng. Nếu ký tự khớp, ta tiếp tục so sánh các ký tự tiếp theo. Nếu ký tự không khớp, ta sử dụng thông tin từ mảng để xác định vị trí mới để tiếp tục tìm kiếm.</p></li><li><p>Nếu ta tìm thấy một vị trí trong chuỗi mà tất cả các ký tự của mẫu khớp, ta đã tìm thấy một kết quả và có thể thực hiện các hành động cần thiết</p></li></ol><p><br/></p><p><br/></p><p>Cài đặt thuật toán</p><p>#include &lt;stdio.h&gt;</p><p>#include &lt;string.h&gt;</p><p>void computeLPSArray(char* pattern, int m, int* lps) {</p><p>    int len = 0;</p><p>    lps[0] = 0;</p><p>    int i = 1;</p><p>    while (i &lt; m) {</p><p>        if (pattern[i] == pattern[len]) {</p><p>            len++;</p><p>            lps[i] = len;</p><p>            i++;</p><p>        } else {</p><p>            if (len != 0) {</p><p>                len = lps[len - 1];</p><p>            } else {</p><p>                lps[i] = 0;</p><p>                i++;</p><p>            }</p><p>        }</p><p>    }</p><p>}</p><p>void KMPSearch(char* pattern, char* text) {</p><p>    int m = strlen(pattern);</p><p>    int n = strlen(text);</p><p>    int lps[m];</p><p>    computeLPSArray(pattern, m, lps);</p><p>    int i = 0;</p><p>    int j = 0;</p><p>    while (i &lt; n) {</p><p>        if (pattern[j] == text[i]) {</p><p>            j++;</p><p>            i++;</p><p>        }</p><p>        if (j == m) {</p><p>            printf("Tim thay mau tai vi tri %d\n", i - j);</p><p>            j = lps[j - 1];</p><p>        } else </p><p>			if (i &lt; n &amp;&amp; pattern[j] != text[i])</p><p>	            if (j != 0)</p><p>	                j = lps[j - 1];</p><p>	            else</p><p>	                i++;</p><p>    }</p><p>    printf("Khong tim thay mau!");</p><p>}</p><p>main() {</p><p>    char text[100],pattern[100];</p><p>    int chon;</p><p>    do{</p><p>	    printf("\nnhap lua chon cua ban\n --1 de nhap\n --so khac de thoat\n");</p><p>	    scanf("%d", &amp;chon);</p><p>	    fflush(stdin);</p><p>	    switch (chon){</p><p>	    	case 1: </p><p>	    		printf("\nnhap chuoi 1: ");</p><p>			    gets(text);</p><p>			    printf("nhap chuoi 2: ");</p><p>				gets(pattern);</p><p>			    KMPSearch(pattern, text);</p><p>			    break;</p><p>			default:</p><p>				printf("Ket thuc chuong trinh!");				</p><p>		}</p><p>	}while (chon ==1);</p><p>}</p>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/1923117646/27f223d904f7121d2d9fda01f2e45932/image.png" />
         <pubDate>2024-01-01 08:18:49 UTC</pubDate>
         <guid>https://padlet.com/22115053122235/t0b1grggqqve9c25/wish/2836224511</guid>
      </item>
      <item>
         <title>4.Nén tập tin(Nguyễn Văn Công)</title>
         <author>22115053122235</author>
         <link>https://padlet.com/22115053122235/t0b1grggqqve9c25/wish/2836224574</link>
         <description><![CDATA[<p><br></p><p>Nén tập tin theo 2 kiểu :</p><p>+file txt</p><p>+file nhị phân</p><p><br></p><p>Mô tả thuật toán :</p><p>-Tạo một vòng lập do while xem người dùng muốn lựa chon file txt hay nhị phân</p><p>+Nếu là txt thì tạo một file f có đường dẫn mặc định và ghi chuỗi vào file bằng hàm fprintf sau đó đóng file, file được tạo mới này sẽ nằm cạnh file cpp</p><p>+Nếu là nhị phân  tạo một file f có đường dẫn mặc định và ghi chuỗi vào file bằng hàm fwrite sau đó đóng file, file được tạo mới này sẽ nằm cạnh file cpp</p><p><br></p><p>Cài đặt thuật toán:</p><p><br></p><p>#include &lt;stdio.h&gt;</p><p>#include &lt;stdlib.h&gt;</p><p>int main(){</p><p>	//B1.Tao file</p><p>	FILE *f;</p><p>	char Test[100];</p><p>	int luachon1,luachon2;</p><p>	do{</p><p>		printf("---------------Nhap lua chon-------------\n");</p><p>		printf("1. File txt\n");</p><p>		printf("2. File nhi phan\n");</p><p>		scanf("%d",&amp;luachon2);</p><p>		switch(luachon2){</p><p>			case 1:{</p><p>				do{</p><p>					printf("---------------Nhap lua chon-------------\n");</p><p>					printf("1. Doc file\n");</p><p>					printf("2. Ghi file\n");</p><p>					scanf("%d",&amp;luachon1);</p><p>					switch(luachon1){</p><p>					case 1:{</p><p>					//Mac dinh f co ten file la : "Taofile.txt" </p><p>					f=fopen("Taofile.txt","r");</p><p>					if(f==NULL){</p><p>						printf("\n Loi tao hoac mo file");</p><p>						exit(1);</p><p>					}</p><p>					//Doc file</p><p>					fscanf(f,"%s",&amp;Test);</p><p>					printf("Gia tri chuoi trong file la : %s\n",Test);</p><p>					//Dong file</p><p>					fclose(f);</p><p>					break;</p><p>				}</p><p>				case 2:{</p><p>				//Tao mot file moi de ghi co ten : "Taofile.txt"</p><p>				f=fopen("Taofile.txt","w");</p><p>				if(f==NULL){</p><p>					printf("\n Loi tao hoac mo file");</p><p>					exit(1);</p><p>				}</p><p>				//Nhap n</p><p>				printf("\nNhap chuoi moi vao file : \n");</p><p>				scanf("%s",&amp;Test);</p><p>				//Dua n vao file</p><p>				fprintf(f,"%s",Test);</p><p>				//Dong file</p><p>				fclose(f);</p><p>				break;</p><p>				}</p><p>					}</p><p>			}while(luachon1!=0);</p><p>				break;</p><p>			}</p><p>			case 2:{</p><p>				do{</p><p>					printf("------------Nhap lua chon-----------\n");</p><p>					printf("1. Doc file\n");</p><p>					printf("2. Ghi file\n");</p><p>					scanf("%d",&amp;luachon1);</p><p>					switch(luachon1){</p><p>						case 1:{</p><p>							f=fopen("TaofileNhiPhan.bin","rb");</p><p>							if(f==NULL){</p><p>								printf("\n Loi tao hoac mo file");</p><p>								exit(1);</p><p>							}</p><p>							fread(&amp;Test,sizeof(Test),1,f);</p><p>							printf("\n Chuoi : %s\n",Test);</p><p>							fclose(f);</p><p>							break;</p><p>						}</p><p>						case 2:{</p><p>							f=fopen("TaofileNhiPhan.bin","wb");</p><p>							if(f==NULL){</p><p>								printf("\n Loi tao hoac mo file");</p><p>								exit(1);</p><p>							}</p><p>							</p><p>							printf("\nNhap chuoi moi vao file : \n");</p><p>							scanf("%s",&amp;Test);</p><p>							</p><p>							fwrite(&amp;Test,sizeof (Test),1,f);</p><p>							</p><p>							fclose(f);</p><p>							</p><p>							break;</p><p>						}</p><p>					}</p><p>				}while(luachon1!=0);</p><p>				break;</p><p>			}</p><p>		}</p><p>		</p><p>	}while(luachon2!=0);</p><p>	</p><p>	return 0;</p><p>}</p>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/2265936747/00b8a3ff4411664ac910698064615d7c/image.png" />
         <pubDate>2024-01-01 08:19:12 UTC</pubDate>
         <guid>https://padlet.com/22115053122235/t0b1grggqqve9c25/wish/2836224574</guid>
      </item>
      <item>
         <title>5. Mật mã(Phan Công Quốc)</title>
         <author>22115053122235</author>
         <link>https://padlet.com/22115053122235/t0b1grggqqve9c25/wish/2836224639</link>
         <description><![CDATA[<p>Input: chuỗi (matMaGoc),chuỗi (matMaNhap)</p><p>Output:  "Mat ma dung" hoặc "Mat ma sai, Nhap lai".</p><p><br/></p><p>Mô tả thuật toán :</p><p>- Yêu cầu nhập mật mã gốc . Mật mã này được lưu lại để sử dụng sau này.</p><p><strong>-</strong> Yêu cầu nhập mật mã. Mỗi ký tự người dùng nhập vào sẽ được thêm vào chuỗi và &nbsp;chương trình sẽ in ra ký tự&nbsp;*&nbsp;để bảo vệ mật mã người dùng.</p><p>- Nếu mật mã người dùng nhập vào khớp với mật mã  gốc đã tạo trước đó, chương trình sẽ thông báo mật mã đúng và kết thúc. Nếu không, chương trình sẽ thông báo mật mã sai và yêu cầu người dùng nhập lại .</p><p><br/></p><p>Cài đặt thuật toán:</p><p><br/></p><p>#include &lt;stdio.h&gt;</p><p>#include &lt;string.h&gt;</p><p>#include &lt;conio.h&gt;</p><p>char* taoMatma() {</p><p>    static char matMaGoc[11];</p><p>    printf("Tao mat ma: ");</p><p>    scanf("%s", matMaGoc);</p><p>    return matMaGoc;</p><p>}</p><p>void kiemTraMatMa(char matMaGoc[]) {</p><p>    char matMaNhap[11];</p><p>    while (1) {</p><p>        printf("Nhap Password\n");</p><p>        int i = 0;</p><p>        char a = getch();</p><p>        while (a != 13 &amp;&amp; a != 10 &amp;&amp; i &lt; 10) {</p><p>            if (a != 8) {</p><p>                printf("*");</p><p>                matMaNhap[i] = a;</p><p>                i++;</p><p>                a = getch();</p><p>            }</p><p>        }</p><p>        matMaNhap[i] = '\0';</p><p>        if (strcmp(matMaGoc, matMaNhap) == 0) {</p><p>            printf("\n");</p><p>            printf("mat ma ban nhap la %s\n", matMaNhap);</p><p>            printf("Mat ma dung\n");</p><p>            break;</p><p>        }</p><p>        else {</p><p>            printf("\nMat ma sai, Nhap lai\n");</p><p>        }</p><p>    }</p><p>}</p><p>int main() {</p><p>    char* matMaGoc= taoMatma();</p><p>    kiemTraMatMa(matMaGoc);</p><p>    return 0;</p><p>}</p><p><br/></p>]]></description>
         <enclosure url="https://padlet-uploads.storage.googleapis.com/1940456418/e7cdca42747860f9b9781fa8086c0095/_nh_ch_p_m_n_h_nh_2024_01_06_231846.png" />
         <pubDate>2024-01-01 08:19:31 UTC</pubDate>
         <guid>https://padlet.com/22115053122235/t0b1grggqqve9c25/wish/2836224639</guid>
      </item>
   </channel>
</rss>
