哈工大(深圳)《计算理论》课程project


所有实验均在Ubuntu下编写和测试,亲测在Windows下结果不正确。

一、project 1

实验一

实验内容:编写程序实现利用正则表达式匹配IP地址。要求能够正确匹配合法的IP地址格式。
很简单,没什么好说的。但听说有很多同学用“调包”的方法,但我至今也没弄清楚调的是什么包。(手动笑哭emoj)
直接放上实验报告里的Design部分。

A. Design
In this experiment, I construct a program to read a regular a ipv4 address and check it if it is a correct one. Specially, we regard those ipv4 address which consist of four number between and 255 and separated by three dots as correct addresses.
So I just read characters into a buffer until meeting a dot, then transform them to corresponding integers and check it if in the range of 0 to 255. If so, go and check the next integer. Otherwise, it’s not a correct ipv4 address. When reading the ‘\0’ means it has been the end of this string, if now exactly 4 integers and 3 dots have been checked, then we say this string is a correct ipv4 address. Otherwise, it’s not.

实验二

实验内容:编写程序实现从正则表达式到非确定性有穷自动机(NFA)的转换。输入数据从文件读取。正则表达式的形式化定义可参考中文课本(第二版)P38相关内容。NFA的形式化定义可参考中文课本(第二版)P32相关内容,并设计数据结构以在计算机中表示。
NFA的数据结构:

// The item of Transition Function List.
typedef struct func{
   
    
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值