#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位校验和的实现
最新推荐文章于 2024-06-14 15:51:52 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)