码迷,mamicode.com
首页 > 编程语言 > 详细

ACM算法练习-——ZJU1164-Software CRC

时间:2018-08-10 19:53:24      阅读:255      评论:0      收藏:0      [点我收藏+]

标签:software   int   pre   bre   ret   链接   col   har   nio   

具体的题目描述点此链接                http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1164

 

这道题,说实话 ,我不懂-.-

我先把这个代码粘在这,具体的这个原因我再研究研究~

 1 #include<stdio.h>
 2 #define Generator 34943
 3 
 4 int main()
 5 {
 6     unsigned char c,flag;
 7     int count;//一行中的字符数
 8     //CRC的数据结构
 9     union
10     {
11         unsigned int L;
12         struct
13         {
14             unsigned char b1;
15             unsigned char b2;
16             unsigned char b3;        
17             unsigned char b4;
18         } crc;
19     }data; 
20     
21     while(1)
22     {
23         count=0;
24         data.L=0;
25         while(scanf("%c",&c)&&c!=\n)
26         {
27             count++;
28             flag=c;
29             data.L=((data.L<<8)+c)%Generator;
30         }
31         
32         data.L=((data.L<<16)+c)%Generator;
33         if(data.L!=0)data.L=Generator-data.L;
34         if(count==1&&flag==#)break;
35         printf("%02X%02X\n",(int)data.crc.b2,(int)data.crc.b1);
36     }
37     return 0;
38 } 

 

ACM算法练习-——ZJU1164-Software CRC

标签:software   int   pre   bre   ret   链接   col   har   nio   

原文地址:https://www.cnblogs.com/lyxcode/p/9456725.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!