Skip to content

Commit 2bcdcf1

Browse files
committed
1.1: strip code
1 parent 2c697d1 commit 2bcdcf1

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

hammingdec.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ void kontrolbit(int *kod, int lengh)
1414
for(int g = 0; g < i + 1; g++)
1515
{
1616
if((start+g != i)&&(start+g < lengh))
17-
summ = summ + kod[start+g];
17+
summ += kod[start+g];
1818
}
19-
start = start + i + i + 2;
19+
start += (i + i + 2);
2020
}
2121
if(kod[i] != summ%2)
2222
{
23-
errorpos = errorpos + i;
23+
errorpos += i;
2424
}
2525
summ = 0;
2626
}
@@ -49,7 +49,7 @@ void tobit(int x, int *byte)
4949
for(int i = 0; i < 8; i++)
5050
{
5151
byte[i] = x%2;
52-
x = x>>1;
52+
x >>= 1;
5353
}
5454
invert(byte);
5555
}
@@ -59,7 +59,7 @@ int todec(int *byte)
5959
int x = 0, st = 7;
6060
for(int i = 0; i < 8; i++)
6161
{
62-
x = x + (byte[i]<<st);
62+
x += (byte[i]<<st);
6363
st--;
6464
}
6565
return x;

hammingenc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ void kontrolbit(int *kod, int lengh)
1414
for(int g = 0; g < i + 1; g++)
1515
{
1616
if((kod[start+g] != 2)&&(start+g < lengh))
17-
summ = summ + kod[start+g];
17+
summ += kod[start+g];
1818
}
19-
start = start + i + i + 2;
19+
start += (i + i + 2);
2020
}
2121
kod[i] = summ%2;
2222
summ = 0;
@@ -39,7 +39,7 @@ void tobit(int x, int *byte)
3939
for(int i = 0; i < 8; i++)
4040
{
4141
byte[i] = x%2;
42-
x = x>>1;
42+
x >>= 1;
4343
}
4444
invert(byte);
4545
}
@@ -49,7 +49,7 @@ int todec(int *byte)
4949
int x = 0, st = 7;
5050
for(int i = 0; i < 8; i++)
5151
{
52-
x = x + (byte[i]<<st);
52+
x += (byte[i]<<st);
5353
st--;
5454
}
5555
return x;

0 commit comments

Comments
 (0)