Latest topics
» Tự học lập trình IOS trong vòng 24hby kenanh 27/1/2014, 22:28
» xin tài liệu một số môn học
by nguyentvvan 21/8/2013, 21:34
» [Thảo luận] Bài toán đong nước
by giathinh9x 9/1/2013, 22:39
» Học Marketing Online, Học Chuyên viên Internet Marketing Online tại iNET
by NIIT-iNET 19/6/2012, 14:23
» Học PHP nâng cao, Học lập trình web với PHP nâng cao tại học viện iNET
by NIIT-iNET 19/6/2012, 14:22
» Học PHP, học lập trình web với PHP tại iNET vào ngày 19/07/2012
by NIIT-iNET 19/6/2012, 14:20
» PHIÊN BẢN MỚI CHO THIÊN ĐƯỜNG CÁ Ô LA LA !!!
by todaytv 13/3/2012, 15:35
» [hot] game khu vườn địa đàng phiên bản mobile của KVTM
by trantinh1713 3/1/2012, 15:20
» Đề tham khảo (update phút 90)
by ndc_2209 29/12/2011, 10:26
» Học bổng Lời Dịch tuần này.
by tienganh123 1/11/2011, 13:13
» [Thảo luận] Quản lý phân công giảng dạy PTTH
by huyquang0510 5/10/2011, 09:52
» Học tiếng Nhật - Top Globis
by tuquynh 21/9/2011, 10:35
» Học tiếng Nhật - Top Globis
by tuquynh 8/8/2011, 11:19
» Order Imitrex Online
by Khách viếng thăm 4/8/2011, 18:46
» Speeds Caffeine Metabolism Up
by Khách viếng thăm 4/8/2011, 18:12
» Skin For Good Caffeine
by Khách viếng thăm 3/8/2011, 14:54
» Cheap Pvc Figures
by Khách viếng thăm 1/8/2011, 19:32
» Action Rapid Onset Zolpidem Of
by Khách viếng thăm 31/7/2011, 01:13
» TUYỂN NHÂN VIÊN KINH DOANH ( làm việc tại văn phòng )
by canhkientp 5/7/2011, 14:59
» Demo + Vài điểm thảo luận về LINQ - Nhóm 7
by ChuongTienPhat 3/7/2011, 12:19
Demo phép cộng 2 số nguyên
2 posters
..:: Diễn đàn lớp 07CK2 - ĐH.KHTN - TP.HCM ::.. :: [ GÓC HỌC TẬP ] :: CÁC MÔN ĐÃ HỌC :: MẠNG MÁY TÍNH
Trang 1 trong tổng số 1 trang
Demo phép cộng 2 số nguyên
// server.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "server.h"
#include "afxsock.h"
#include "conio.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
AfxSocketInit(NULL);
CSocket server, s;
int a, b, c;
int cont = 1;
server.Create(2345);
server.Listen();
int temp = server.Accept(s);
if (temp)
{
do
{
s.Receive(&a, sizeof (int));
s.Receive(&b, sizeof (int));
c = a + b;
printf ("%d + %d = %d", a, b, c);
printf ("\nCo muon tiep tuc khong? 0/1");
scanf ("%d", &cont);
s.Send(&cont, sizeof (int));
} while (cont != 0);
}
s.Close();
server.Close();
}
getch();
return nRetCode;
}
//
#include "stdafx.h"
#include "server.h"
#include "afxsock.h"
#include "conio.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
AfxSocketInit(NULL);
CSocket server, s;
int a, b, c;
int cont = 1;
server.Create(2345);
server.Listen();
int temp = server.Accept(s);
if (temp)
{
do
{
s.Receive(&a, sizeof (int));
s.Receive(&b, sizeof (int));
c = a + b;
printf ("%d + %d = %d", a, b, c);
printf ("\nCo muon tiep tuc khong? 0/1");
scanf ("%d", &cont);
s.Send(&cont, sizeof (int));
} while (cont != 0);
}
s.Close();
server.Close();
}
getch();
return nRetCode;
}
Re: Demo phép cộng 2 số nguyên
// client.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "client.h"
#include "afxsock.h"
#include "conio.h"
#include "stdio.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
AfxSocketInit(NULL);
CSocket client;
int a, b, cont;
char temp[50];
client.Create();
int k = client.Connect("127.0.0.1", 2345);
if (k)
{
do
{
printf ("a = ");
gets(temp);
a = atoi(temp);
printf ("b = ");
gets(temp);
b = atoi(temp);
client.Send(&a, sizeof (int));
client.Send(&b, sizeof (int));
client.Receive(&cont, sizeof (int));
} while (cont != 0);
}
client.Close();
}
getch();
return nRetCode;
}
//
#include "stdafx.h"
#include "client.h"
#include "afxsock.h"
#include "conio.h"
#include "stdio.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
AfxSocketInit(NULL);
CSocket client;
int a, b, cont;
char temp[50];
client.Create();
int k = client.Connect("127.0.0.1", 2345);
if (k)
{
do
{
printf ("a = ");
gets(temp);
a = atoi(temp);
printf ("b = ");
gets(temp);
b = atoi(temp);
client.Send(&a, sizeof (int));
client.Send(&b, sizeof (int));
client.Receive(&cont, sizeof (int));
} while (cont != 0);
}
client.Close();
}
getch();
return nRetCode;
}
Re: Demo phép cộng 2 số nguyên
cái này Nam làm hả? chạy ra ko Nam?
nguyenhoainam- [ Súp bơ man nhìu chjện ]
-
Tổng số bài gửi : 687
Age : 35
Location : Q.13, TPHCM
Registration date : 26/03/2008
Similar topics
» Tài Liệu Demo 29/10/210
» Tạo nguyệt thực
» 19/04/09: Dạy học tình nguyện ở Thảo Đàn
» Éo Le Cuộc Tình
» Tài liệu DEMO 15/03/2010
» Tạo nguyệt thực
» 19/04/09: Dạy học tình nguyện ở Thảo Đàn
» Éo Le Cuộc Tình
» Tài liệu DEMO 15/03/2010
..:: Diễn đàn lớp 07CK2 - ĐH.KHTN - TP.HCM ::.. :: [ GÓC HỌC TẬP ] :: CÁC MÔN ĐÃ HỌC :: MẠNG MÁY TÍNH
Trang 1 trong tổng số 1 trang
Permissions in this forum:
Bạn không có quyền trả lời bài viết
|
|