91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 40KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-07
  • 語言: 其他
  • 標簽: arq??

資源簡介

實驗要求實現發送方send將界面讀入的數據保存到文件file1.txt中,并啟動計時器;接收方receive從file1.txt中查找是否有新字符到來,并提供模擬界面給用戶選擇{1.接收,2.丟棄,3.超時},并將用戶選擇的結果記錄到file2.txt中;發送方讀取file2.txt 決定下面的操作{如果是1,則繼續接收用戶輸入;如果是2,則重傳該字符;3.如果是3,則重傳該字符}。并將接收的字符保存到file3.txt 中。 【注】:file1.txt要發送的串, file2.txt保存中間結果, file3.txt接受的串。

資源截圖

代碼片段和文件信息

#include?“stdafx.h“
#include?
#include?
#include?
#include?
#include?
using?namespace?std;
class?send//傳送類
????{
private:
string?sendMsg;//連續傳送個幀
????????string?revert;//接受方的回復
public:
void?writeFile1(string?msg)//將需要傳輸的數據寫入file1
{
fstream?file1;//發送文件
file1.open(“file1.txt“ios::out);
if(!file1)
{
cout<<“file1打開失敗!“< }
file1< file1.close();//關閉文件
}

void?setSendMsg(int?sp)//設置傳送的個幀
????????{
if(sp?==?8)//本幀首次傳輸
{
fstream?file_1(“file1.txt“ios::in);
if(!file_1)
{
cout<<“file1打開失敗!“< }
file_1>>sendMsg;
file_1.close();
}
else//從錯誤的幀開始傳輸
{
sendMsg.erase(0sp);
fstream?file_1(“file1.txt“ios::out);
if(!file_1)
{
cout<<“file1打開失敗!“< }
file_1< file_1.close();
}
????????}

????int?getStart(int?sp)//從file2中讀取接受方的回復,設置要傳送數據的開始位置
{
fstream?file_2(“file2.txt“ios::in|ios::out);
file_2>>revert;
file_2.close();
int?i?=?0;
for(?;i? {
if(revert[i]?!=?‘1‘)
break;
}
if(i?==?revert.length())
{
cout<<“5幀全部傳輸成功!!!“< return?9;//表示全部傳輸成功
}
else
{
cout<<“在第“< return?i;
}

}

????};


class?receive//接收類
????{
private:
????char?ReceiveNum[5];
public:
void?controlMsg()//處理信息,提示.接收該字符.丟棄該字符.超時處理,并將接收的數據放入file3中
{
string?temp;
fstream?file_1(“file1.txt“ios::in);
if(!file_1)
{
cout<<“file1打開失敗!“< }
file_1>>temp;
file_1.close();
if(temp.length())//有新字符
{
cout< cout<<“1.接收該字符???????2.丟棄該字符???????3.超時處理“< fstream?file_2(“file2.txt“ios::out);
for(int?i?=?0;i? {
cout<<“對于第“< cin>>ReceiveNum[i];
while(ReceiveNum[i]?!=?‘1‘?&&ReceiveNum[i]?!=?‘2‘&&ReceiveNum[i]?!=?‘3‘)
{
cout<<“輸入錯誤,請重新輸入:“;
cin>>ReceiveNum[i];
}
file_2< }//for(int?i?=?0;i? file_2.close();
for(int?j?=?0;ReceiveNum[j]?==?‘1‘&&j? {
fstream?file_3(“file3.txt“ios::app);
file_3< file_3.close();
}
}//if(!temp)
}
????};


int?main(int?argcchar*?argv[])
{
using?namespace?std;
send?s;
receive?r;

fstream?file2;//中間過程存儲文件
fstream?file3;//接收文件
clock_t?start?finish;
double???duration;
string?information;
cout<<“請輸入要傳輸的數據:“< cin>>information;
cout<<“信息傳輸中……“< start?=?clock();?

int?wp?=?0;//傳送文本的指針

????string?sendMsg;
while?(true)
????{

sendMsg.clear();
for?(;wp?????????{
int?sp?=?8;//實際傳送文本的指針
sendMsg.assign(informationwp5);//將屏幕中要傳送的信息給sen

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????3710??2008-09-22?22:12??040640208?霍瑛\ARQ.cpp

?????文件??????78336??2008-09-22?22:13??040640208?霍瑛\ARQ協議模擬實現.doc

?????文件????????208??2008-09-13?22:46??040640208?霍瑛\stdafx.cpp

?????文件????????236??2008-09-17?12:35??040640208?霍瑛\stdafx.h

?????目錄??????????0??2008-09-23?22:10??040640208?霍瑛

-----------?---------??----------?-----??----

????????????????82490????????????????????5


評論

共有 條評論