<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Thế Vương</title>
	<atom:link href="http://thevuong.tk/feed/" rel="self" type="application/rss+xml" />
	<link>http://thevuong.tk</link>
	<description>Vui Học Lập Trình :)</description>
	<lastBuildDate>Wed, 27 Feb 2013 12:19:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Chương trình tính bậc đồ thị có hướng sử dụng Ma trận liên thuộc</title>
		<link>http://thevuong.tk/toan-roi-rac-2/2013/02/chuong-trinh-tinh-bac-do-thi-co-huong-su-dung-ma-tran-lien-thuoc/</link>
		<comments>http://thevuong.tk/toan-roi-rac-2/2013/02/chuong-trinh-tinh-bac-do-thi-co-huong-su-dung-ma-tran-lien-thuoc/#comments</comments>
		<pubDate>Wed, 27 Feb 2013 09:02:12 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Toán Rời Rạc 2]]></category>
		<category><![CDATA[biểu diễn đồ thị]]></category>
		<category><![CDATA[ma trận liên thuộc]]></category>
		<category><![CDATA[tính bậc đồ thị]]></category>
		<category><![CDATA[toán rời rạc 2]]></category>

		<guid isPermaLink="false">http://thevuong.tk/?p=40</guid>
		<description><![CDATA[Cấu trúc File “DoThi.txt” trình bày theo mẫu như sau. 5 1 4 2 1 4 2 2 5 5 4 4 3 trong đó 5 là số đỉnh, 1 4 là cạnh 4 kề 1.]]></description>
				<content:encoded><![CDATA[<p>Cấu trúc File “DoThi.txt” trình bày theo mẫu như sau.<br />
5<br />
1 4<br />
2 1<br />
4 2<br />
2 5<br />
5 4<br />
4 3<br />
trong đó 5 là số đỉnh, 1 4 là cạnh 4 kề 1.</p>
<p><span id="more-40"></span></p>
<pre class="brush: cpp; title: Author: The Vuong; notranslate">// Chuong trinh: Tinh bac do thi co huong su dung ma tran lien thuoc
// Author: The Vuong
// Copyright (c) 2013
// Date: 27/02/2013
// Website: http://thevuong.tk
// Facebook: https://www.facebook.com/groups/xcode11/

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;conio.h&gt;

#define DAU 1
#define CUOI -1
#define RONG 0

/*Khai bao nguyen mau ham*/
void DocFile ();
void TinhBac ();

/*Khai bao bien toan cuc*/
int **A; //Ma tran lien thuoc 2 chieu
int n; //So dinh
int m; //So canh
char tenFile[] = &quot;DoThi.txt&quot;;

int main () {
	DocFile ();
	TinhBac ();
	for (int i =  0; i &lt; m; i++)
		delete [] A[i];
	delete [] A;
	getch ();
	return (0);
}

void DocFile () {
	int i, j, k = 0;
	FILE *fp = fopen (tenFile, &quot;r&quot;);
	if (fp == NULL) {
		printf (&quot;Khong co file %s\n&quot;, tenFile);
		exit (0);
	}
	m = 0;
	/*Dem so dong trong File, so dong se tuong ung voi so cung/canh*/
	while (!feof (fp)) { /*Ham foef (); tra ve 1 khi tro den cuoi file*/
		if (fgetc (fp) == '\n')
			m++;
	}
	/*Di chuyen co tro fp ve dau file*/
	rewind (fp);
	/*Doc so dinh*/
	fscanf (fp, &quot;%d&quot;, &amp;n);
	/*Tao danh sach dong Ma Tran Lien Thuoc*/
	A = new int *[n];
	for (i = 0; i &lt; n; i++)
		A[i] = new int [m];
	/*Khoi tao ma tran rong*/
	for (i = 0; i &lt; n; i++)
		for (j = 0; j &lt; m; j++)
			A[i][j] = RONG;
	/*Doc danh sach dinh dau, cuoi*/
	while (fscanf (fp, &quot;%d%d&quot;, &amp;i, &amp;j) != EOF){
		A[i-1][k] = DAU;
		A[j-1][k++] = CUOI;
	}
	fclose (fp);
}

void TinhBac () {
	int vao, ra;
	int i, j;
	for (i = 0; i &lt; n; i++) { /*Duyet dinh tu dinh 0 den n-1*/
		vao = ra = 0;
		for (j = 0; j &lt; m; j++) { /*Duyet cot tu 0 den n-1*/
			if (A[i][j] == DAU)
				ra++;
			if (A[i][j] == CUOI)
				vao++;
		}
		printf (&quot;Dinh %d co bac ra = %d, vao = %d\n&quot;, i + 1, ra, vao);
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://thevuong.tk/toan-roi-rac-2/2013/02/chuong-trinh-tinh-bac-do-thi-co-huong-su-dung-ma-tran-lien-thuoc/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Chương trình tính bậc đồ thị có hướng sử dụng Danh sách cung</title>
		<link>http://thevuong.tk/toan-roi-rac-2/2013/02/chuong-trinh-tinh-bac-do-thi-co-huong-su-dung-danh-sach-cung/</link>
		<comments>http://thevuong.tk/toan-roi-rac-2/2013/02/chuong-trinh-tinh-bac-do-thi-co-huong-su-dung-danh-sach-cung/#comments</comments>
		<pubDate>Wed, 27 Feb 2013 08:51:21 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Toán Rời Rạc 2]]></category>
		<category><![CDATA[biểu diễn đồ thị]]></category>
		<category><![CDATA[Danh sách cung]]></category>
		<category><![CDATA[toán rời rạc]]></category>
		<category><![CDATA[toán rời rạc 2]]></category>

		<guid isPermaLink="false">http://thevuong.tk/?p=36</guid>
		<description><![CDATA[Cấu trúc File &#8220;DoThi.txt&#8221; trình bày theo mẫu như sau. 5 1 4 2 1 4 2 2 5 5 4 4 3 trong đó 5 là số đỉnh, 1 4 là cạnh 4 kề 1.]]></description>
				<content:encoded><![CDATA[<p>Cấu trúc File &#8220;DoThi.txt&#8221; trình bày theo mẫu như sau.<br />
5<br />
1 4<br />
2 1<br />
4 2<br />
2 5<br />
5 4<br />
4 3<br />
trong đó 5 là số đỉnh, 1 4 là cạnh 4 kề 1.<br />
<span id="more-36"></span></p>
<pre class="brush: cpp; title: Author: The Vuong; notranslate">
// Chuong trinh: Tinh bac do thi co huong su dung danh sach cung
// Author: The Vuong
// Copyright (c) 2013
// Date: 27/02/2013
// Website: http://thevuong.tk
// Facebook: https://www.facebook.com/groups/xcode11/

//Doc File vao danh sach cung, sau do tinh bac cua moi dinh
#include &lt;stdio.h&gt; //Su dung ham printf (); scanf (); fscanf (); fopen (); fclose ();
#include &lt;stdlib.h&gt; // Su dung ham exit ();
#include &lt;conio.h&gt; //Su dung ham getch ();

int **A; //Danh sach cung 2 cot, cot 0 vao, cot 1 ra
int n; //So dinh
int m; //So canh/cung
char tenFile[] = &quot;DoThi.txt&quot;;

/*Doc du lieu tu File &quot;DoThi.txt&quot; dua vao ma tran A;*/
void DocFile ();
/*Duyet tung dinh, tuong ung voi moi dinh tinh bac ra theo A[j][0], bac vao A[j][1]*/
void TinhBac ();

int main () {
	DocFile ();
	TinhBac ();
	for (int i = 0; i &lt; m; i++)
		delete [] A[i];
	delete [] A;
	getch ();
	return (0);
}

void DocFile () {
	int i;
	/*Mo file &quot;DoThi.txt&quot; va con tro fp tro den phan tu dau tien trong file*/
	FILE *fp = fopen (tenFile, &quot;r&quot;);
	if (fp == NULL) {
		printf (&quot;Khong co File %s\n&quot;, tenFile);
		exit (0); //Thoat khoi ham
	}
	m = 0;
	/*Dem so dong trong File, so dong se tuong ung voi so cung/canh*/
	while (!feof (fp)) { /*Ham foef (); tra ve 1 khi tro den cuoi file*/
		if (fgetc (fp) == '\n')
			m++;
	}
	rewind (fp); /*Di chuyen co tro fp ve dau file*/
	fscanf (fp, &quot;%d&quot;, &amp;n); //Doc so dinh, con tro fp se tro den phan tu tiep theo
	/*Cap phat mang dong 2 chieu*/
	A = new int *[m]; //So dong = so canh/cung
	for (i = 0; i &lt; m; i++)
		A[i] = new int [2];
	i = 0;
	while (fscanf (fp, &quot;%d%d&quot;, &amp;A[i][0], &amp;A[i][1]) != EOF)
		i++;
	fclose (fp); //Dong file
}

void TinhBac () {
	int vao, ra;
	for (int i = 1; i &lt;= n; i++) { //Duyet dinh
		vao = ra = 0; //Khoi dong lai bac vao, ra sau moi lan duyet dinh
		for (int j = 0; j &lt; m; j++) { //Tung ung voi dinh i, duyet ma tran danh sach m canh/cung
			if (i == A[j][0]) //Tuong ung voi dinh i dem xem co bao nhieu dinh i trong danh sach dinh vao
				ra++;
			if (i == A[j][1]) //Tuong tu, dem xem co bao nhieu dinh i trong danh sach dinh ra
				vao++;
		}
		printf (&quot;Dinh %d co bac ra = %d, vao = %d\n&quot;, i, ra, vao);
	}
}

/* Vi du ma tran danh sach cung/canh
 *  +-------+-------+
 *  |  RA   |  VAO  |
 *  +-------+-------+
 *
 *  +-------+-------+
 *  |   0   |   1   |  Cot 0 bac vao, 1 bac ra
 *  +-------+-------+
 *
 *  +-------+-------+
 *  |   3   |   1   |
 *  +-------+-------+
 *  |   3   |   5   |
 *  +-------+-------+
 *  |   5   |   2   |
 *  +-------+-------+
 */
</pre>
]]></content:encoded>
			<wfw:commentRss>http://thevuong.tk/toan-roi-rac-2/2013/02/chuong-trinh-tinh-bac-do-thi-co-huong-su-dung-danh-sach-cung/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chương trình quản lý danh sách sinh viên</title>
		<link>http://thevuong.tk/cau-truc-du-lieu/2013/02/chuong-trinh-quan-ly-danh-sach-sinh-vien/</link>
		<comments>http://thevuong.tk/cau-truc-du-lieu/2013/02/chuong-trinh-quan-ly-danh-sach-sinh-vien/#comments</comments>
		<pubDate>Sun, 24 Feb 2013 15:31:47 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Cấu Trúc Dữ Liệu]]></category>
		<category><![CDATA[cấu trúc dữ liệu]]></category>
		<category><![CDATA[quản lý sinh viên]]></category>

		<guid isPermaLink="false">http://thevuong.tk/?p=25</guid>
		<description><![CDATA[Chương trình quản lý sinh viên. Trường dữ liệu &#8220;Mã số&#8221;, &#8220;Họ&#8221;, &#8220;Tên&#8221;. Tạo menu chương trình, nhập, xuất, tìm kiếm, chỉnh sửa, sắp xếp theo tên&#8230; trùng tên theo họ.]]></description>
				<content:encoded><![CDATA[<p>Chương trình quản lý sinh viên. Trường dữ liệu &#8220;Mã số&#8221;, &#8220;Họ&#8221;, &#8220;Tên&#8221;.<br />
Tạo menu chương trình, nhập, xuất, tìm kiếm, chỉnh sửa, sắp xếp theo tên&#8230; trùng tên theo họ.<br />
<span id="more-25"></span></p>
<pre class="brush: cpp; title: Author: The Vuong; notranslate">
// Chuong trinh quan ly danh sach sinh vien
// Author: The Vuong
// Copyright (c) 2013
// Website: http://thevuong.tk
// Facebook: https://www.facebook.com/groups/xcode11/

#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;conio.h&gt;
#include &lt;windows.h&gt;

#define TRUE 1
#define FALSE 0
#define MAX 100

struct SinhVien {
    int maSo;
    char ho[35];
    char ten[35];
};

struct List {
    SinhVien nodes[MAX];
    int n; // So sinh vien
};

void QuanLySinhVien (struct List ds);
int Menu ();

void NhapDanhSach (struct List &amp;ds);
void SapXep (struct List &amp;ds);
void LietKeDanhSach (struct List ds);
void InThongTinSinhVien (struct List ds, int maSo);
void SuaThongTin (struct List &amp;ds, int maSo);
void XoaSinhVien (struct List &amp;ds, int maSo);

int TimMaSo (struct List ds, int maSo);
int KiemTraMaSo (struct List ds, int maSo);

int main () {
    List ds;
    ds.n = 0;
    QuanLySinhVien (ds);
    return (0);
}

void QuanLySinhVien (struct List ds) {
    int chon, kiemTra = FALSE;
    int maSo;
    do {
        chon = Menu ();
        switch (chon) {
            case 1: {
                printf (&quot;\n\n\tNHAP SANH SACH\n\n&quot;);
                NhapDanhSach (ds);
                break;
            }
            case 2: {
                printf (&quot;\n\n\tSAP XEP DANH SACH\n\n&quot;);
                SapXep (ds);
                printf (&quot;\n&quot;);
                getch();
                break;
            }
            case 3: {
                printf (&quot;\n\n\tLIET KE DANH SACH\n\n&quot;);
                LietKeDanhSach (ds);
                printf (&quot;\n&quot;);
                getch();
                break;
            }
            case 4: {
                printf (&quot;\n\n\tTHONG TIN SINH VIEN\n\n&quot;);
                printf (&quot;Nhap ma so: &quot;);
                scanf (&quot;%d&quot;, &amp;maSo);
                InThongTinSinhVien (ds, maSo);
                printf (&quot;\n&quot;);
                getch();
                break;
            }
            case 5: {
                printf (&quot;\n\n\tSUA THONG TIN\n\n&quot;);
                printf (&quot;Nhap ma so: &quot;);
                scanf (&quot;%d&quot;, &amp;maSo);
                SuaThongTin (ds, maSo);
                printf (&quot;\n&quot;);
                getch();
                break;
            }
            case 6: {
                printf (&quot;\n\n\tXOA SINH VIEN\n\n&quot;);
                printf (&quot;Nhap ma so: &quot;);
                scanf (&quot;%d&quot;, &amp;maSo);
                XoaSinhVien (ds, maSo);
                printf (&quot;\n&quot;);
                getch();
                break;
            }
            case 0: {
                kiemTra = TRUE;
                break;
            }
        }
    } while (!kiemTra);
}

int Menu () {
    char c;
    system (&quot;cls&quot;);
    printf (&quot;\n +------------------------------------+&quot;);
    printf (&quot;\n +              MENU                  +&quot;);
    printf (&quot;\n +------------------------------------+&quot;);
    printf (&quot;\n +      1. Nhap Danh Sach             +&quot;);
    printf (&quot;\n +      2. Sap Xep Danh Sach          +&quot;);
    printf (&quot;\n +      3. Liet Ke Danh Sach          +&quot;);
    printf (&quot;\n +      4. Thong Tin Sinh Vien        +&quot;);
    printf (&quot;\n +      5. Sua Thong Tin              +&quot;);
    printf (&quot;\n +      6. Xoa Sinh Vien              +&quot;);
    printf (&quot;\n +------------------------------------+&quot;);
    printf (&quot;\n +      0. Thoat                      +&quot;);
    printf (&quot;\n +------------------------------------+&quot;);
    printf (&quot;\nChon muc: &quot;);
    do {
        c = getche ();
    } while (c &lt; '0' || c &gt; '6');
    return c - '0';
}

void NhapDanhSach (struct List &amp;ds) {
    int tam, kiemTra = FALSE;
    do {
        printf (&quot;Nhap ma so sinh vien (Nhap 0 de thoat!): &quot;);
        scanf (&quot;%d&quot;, &amp;tam);
        if (tam &lt; 1)
            kiemTra = TRUE;
        else {
            if (KiemTraMaSo (ds, tam)) {
                ds.nodes[ds.n].maSo = tam;
                printf (&quot;Ho: &quot;);
                fflush (stdin);
                gets (ds.nodes[ds.n].ho);
                printf (&quot;Ten: &quot;);
                fflush (stdin);
                gets (ds.nodes[ds.n].ten);
                ds.n++;
           }
            else
                printf (&quot;\tMa so trung. Moi nhap lai!\n&quot;);
        }
    } while (!kiemTra);
}

void SapXep (struct List &amp;ds) {
    SinhVien tam;
    for (int i = 0; i &lt; ds.n - 1; i++)
        for (int j = i + 1; j &lt; ds.n; j++)
            if (strcmp(ds.nodes[i].ten, ds.nodes[j].ten) &gt; 0) {
                tam = ds.nodes[i];
                ds.nodes[i] = ds.nodes[j];
                ds.nodes[j] = tam;
            }
            else if (strcmp(ds.nodes[i].ten, ds.nodes[j].ten) == 0 &amp;&amp; strcmp(ds.nodes[i].ho, ds.nodes[j].ho) &gt; 0) {
                tam = ds.nodes[i];
                ds.nodes[i] = ds.nodes[j];
                ds.nodes[j] = tam;
            }
    LietKeDanhSach (ds);
}

void LietKeDanhSach (struct List ds) {
    printf (&quot;\n\t\tDANH SACH SINH VIEN\n&quot;);
    printf (&quot;+-------+----------------------+--------------------------+\n&quot;);
    printf (&quot;| MA SO |           HO         |            TEN           |\n&quot;);
    printf (&quot;+-------+----------------------+--------------------------+\n&quot;);
    for (int i = 0; i &lt; ds.n; i++)
        printf (&quot;| %-5d| %-21s| %-25s|\n&quot;, ds.nodes[i].maSo, ds.nodes[i].ho, ds.nodes[i].ten);
    printf (&quot;+-------+----------------------+--------------------------+\n&quot;);
}

void InThongTinSinhVien (struct List ds, int maSo) {
    int viTri;
    if ((viTri = TimMaSo (ds, maSo)) != -1) {
        printf (&quot;\n\t\tTHONG TIN SINH VIEN\n&quot;);
        printf (&quot;+-------+----------------------+--------------------------+\n&quot;);
        printf (&quot;| MA SO |           HO         |            TEN           |\n&quot;);
        printf (&quot;+-------+----------------------+--------------------------+\n&quot;);
        printf (&quot;| %-5d| %-21s| %-25s|\n&quot;, ds.nodes[viTri].maSo, ds.nodes[viTri].ho, ds.nodes[viTri].ten);
        printf (&quot;+-------+----------------------+--------------------------+\n&quot;);
    }
    else
        printf (&quot;\tMa so %d khong co trong danh sach&quot;, maSo);
}

void SuaThongTin (struct List &amp;ds, int maSo) {
    int viTri;
    if ((viTri = TimMaSo (ds, maSo)) != -1) {
        printf (&quot;\tHo cu: &quot;);
        puts (ds.nodes[viTri].ho);
        printf (&quot;Ho moi: &quot;);
        fflush (stdin);
        gets (ds.nodes[viTri].ho);
        printf (&quot;\tTen cu: &quot;);
        puts (ds.nodes[viTri].ten);
        printf (&quot;Ten moi: &quot;);
        fflush (stdin);
        gets (ds.nodes[viTri].ten);
    }
    else
        printf (&quot;\tMa so %d khong trong danh sach&quot;, maSo);
}

void XoaSinhVien (struct List &amp;ds, int maSo) {
    int viTri;
    if ((viTri = TimMaSo (ds, maSo)) != -1) {
        for (int i = viTri + 1; i &lt; ds.n; i++)
            ds.nodes[viTri - 1] = ds.nodes[viTri];
        ds.n--;
        printf (&quot;\tXoa thanh cong!&quot;);
    }
    else
        printf (&quot;\tMa so %d khong co trong danh sach&quot;, maSo);
}

int TimMaSo (struct List ds, int maSo) {
    for (int i = 0; i &lt; ds.n; i++)
        if (ds.nodes[i].maSo == maSo)
            return (i);
    return (-1);
}

int KiemTraMaSo (struct List ds, int maSo) {
    for (int i = 0; i &lt; ds.n; i++)
        if (ds.nodes[i].maSo == maSo)
            return (0);
    return (1);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://thevuong.tk/cau-truc-du-lieu/2013/02/chuong-trinh-quan-ly-danh-sach-sinh-vien/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chương trình kiểm tra đồ thị hai phía</title>
		<link>http://thevuong.tk/toan-roi-rac-2/2013/02/chuong-trinh-kiem-tra-do-thi-hai-phia/</link>
		<comments>http://thevuong.tk/toan-roi-rac-2/2013/02/chuong-trinh-kiem-tra-do-thi-hai-phia/#comments</comments>
		<pubDate>Wed, 20 Feb 2013 13:26:05 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Toán Rời Rạc 2]]></category>
		<category><![CDATA[đồ thị hai phía]]></category>

		<guid isPermaLink="false">http://thevuong.tk/?p=15</guid>
		<description><![CDATA[Trong Lý thuyết đồ thị, đồ thị hai phía (tiếng Anh: bipartite graph) là một đồ thị đặc biệt, trong đó tập các đỉnh có thể được chia thành hai tập không giao nhau thỏa mãn điều kiện không có cạnh nối hai đỉnh bất kỳ thuộc cùng một tập. Đồ thị hai phía xuất [...]]]></description>
				<content:encoded><![CDATA[<blockquote><p>Trong Lý thuyết đồ thị, đồ thị hai phía (tiếng Anh: bipartite graph) là một đồ thị đặc biệt, trong đó tập các đỉnh có thể được chia thành hai tập không giao nhau thỏa mãn điều kiện không có cạnh nối hai đỉnh bất kỳ thuộc cùng một tập.<br />
Đồ thị hai phía xuất hiện trong các bài toán dùng đồ thị biểu diễn quan hệ hai ngôi giữa hai tập A và tập B không giao nhau. Một ví dụ cho quan hệ này là quan hệ hôn nhân giữa hai tập hợp người nam và nữ.</p>
<p style="text-align: right;">- Wikipedia</p>
</blockquote>
<p><span id="more-15"></span></p>
<pre class="brush: cpp; title: Author: The Vuong; notranslate">
#include &lt;stdio.h&gt;
#include &lt;conio.h&gt;

#define MAX 20
#define TRUE 1
#define FALSE 0

int x[MAX], y[MAX], t[MAX];
int a[MAX][MAX]; // Ma tran ke
int demX, demY, demT;
int n; // So dinh

void DocFile ();
void KhoiDong (int i);
int NhanGiaTri (int x[], int giaTri, int &amp;dem);
int Giao (int x[], int y[], int demX, int demY, int co);
void DoThiHaiPhia ();
void InKetQua (int x[], int dem, char c);

int main() {
    DocFile ();
    KhoiDong (1);
    DoThiHaiPhia ();
    InKetQua (y, demY, 'X');
    InKetQua (t, demT, 'Y');
    getch ();
    return 0;
}

void DocFile () {
    int i, j;
    FILE *f = fopen (&quot;DoThi.txt&quot;, &quot;r&quot;);
    fscanf (f, &quot;%d&quot;, &amp;n);
    for (i = 1; i &lt;= n; i++)
        for (j = 1; j &lt;= n; j++)
            a[i][j] = FALSE;
    while (fscanf (f, &quot;%d%d&quot;, &amp;i, &amp;j) != EOF) {
        a[i][j] = TRUE;
        a[j][i] = TRUE;
    }
    fclose (f);
}

void KhoiDong (int i) {
    x[1] = i;
    demX = 1;
}

int NhanGiaTri (int x[], int giaTri, int &amp;dem) {
    for (int i = 1; i &lt;= dem; i++)
        if (x[i] == giaTri)
        return (0);
    x[++dem] = giaTri;
}

int Giao (int x[], int y[], int demX, int demY, int co) {
// Co: 0 - Khong xet trung nhau
    if (co) {
        int dem = 0;
        for (int i = 1; i &lt;= demX; i++)
            for (int j = 1; j &lt;= demY; j++)
                if (x[i] == y[j])
                    dem++;
    if (dem == demX)
        return 1;
    return 0;
    }
    else {
        for (int i = 1; i &lt;= demX; i++)
            for (int j = 1; j &lt;= demY; j++)
                if (x[i] == y[j])
                    return 1;
        return 0;
    }
}

void DoThiHaiPhia () {
    int dieuKien = TRUE;
    do {
        demY = demT = 0;
        for (int i = 1; i &lt;= demX; i++)
            for (int j = 1; j &lt;= n; j++)
                if (a[x[i]][j])
                    NhanGiaTri (y, j, demY);
        if (!Giao (x, y, demX, demY, 0)) {
            for (int i = 1; i &lt;= demY; i++)
                for (int j = 1; j &lt;=n; j++)
                    if (a[y[i]][j])
                        NhanGiaTri (t, j, demT);
            if (!Giao (y, t, demY, demT, 0)) {
                if(Giao (x, t, demX, demY, 1)) {
                    printf (&quot;Do thi la hai phia&quot;);
                    dieuKien = FALSE;
                }
                else {
                    for (int i = 1; i &lt;= demT; i++)
                        x[i] = t[i];
                    demX = demT;
                }
            }
            else {
                int T = Giao (y, t, demY, demT, 0);
                printf (&quot;Do thi khong phai la hai phia\n&quot;);
                dieuKien = FALSE;
            }
        }
        else {
            printf (&quot;Do thi khong phai la hai phia\n&quot;);
            dieuKien = FALSE;
        }
    } while (dieuKien);
}

void InKetQua (int x[], int dem, char c) {
    printf (&quot;\nDinh %c: &quot;, c);
    for (int i = 1; i&lt;= dem; i++)
        printf (&quot;%3d&quot;, x[i]);
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://thevuong.tk/toan-roi-rac-2/2013/02/chuong-trinh-kiem-tra-do-thi-hai-phia/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Hosting24 Analytics Code -->
<script type="text/javascript" src="http://stats.hosting24.com/count.php"></script>
<!-- End Of Analytics Code -->
