#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
using namespace std;
struct M
{
int hegiht;
int low;
};
struct MM
{
M m1;
M m2;
};
MM add(MM g1, MM g2)
{
MM demo;
int f[4] = { 0 };
int ff[4] = { 0 };
int c1, c2, c3, c4;
c1 = g1.m2.low + g2.m2.low;
if (c1 >= 16) f[3] = 1;
c2 = g1.m2.hegiht + g2.m2.hegiht;
if (c2 >= 16) f[2] = 1;
c3 = g1.m1.low + g2.m1.low;
if (c3 >= 16) f[1] = 1;
c4 = g1.m1.hegiht + g2.m1.hegiht;
if (c4 >= 16)f[0] = 1;
/* if ((c1 + f[0]) / 16) ff[3] = 1;
demo.m2.low = (c1 + f[0]) % 16;
if ((c2 + f[3] + ff[3]) / 16) ff[2] = 1;
demo.m2.hegiht = (c2 + f[3]+ff[3]) % 16;
if ((c3 + f[2] + ff[2]) / 16) ff[1] = 1;
demo.m1.low = (c3 + f[2]+ff[2]) % 16;
demo.m1.hegiht = (c4 + f[1]+ff[1
计算机网络中,16位校验和的实现
最新推荐文章于 2021-06-15 18:04:01 发布
本文详细介绍了如何在计算机网络中实现16位校验和的算法。通过读取文本文件中的每个字符,将字符转换为16进制,并与下一个字符组合形成双16进制数值,然后进行累加,最终得到校验和。
摘要由CSDN通过智能技术生成