|   
 UID1 威望1240 点 金钱24019 金币 点卡317 点 
 | 
1#
 发表于 2002-10-27 02:52 
 | 只看该作者 
 let us help somebody!
| [这个贴子最后由cnangel在 2002/10/27 03:53am 编辑] 
 /*此程序用来编写一本英文字典,从yuanshi.txt中读取数据,进行编排之后,写入Edictry.txt中,但是我怎么调试都不行。
 编译可以通过,有时候可以运行,但结果是错的,有时候就不能运行。
 我曾经有过很多次这样的经历,只要程序稍微“大”了一点,它就会给我出莫名其妙的问题,搞得我头都大了。
 各位大侠,help!!!
 */
 #include "stdio.h"
 #include "string.h"
 #define LEN sizeof(struct str)
 #define NULL 0
 struct str{
 char *s;
 char *h;
 struct str *next;
 };
 struct str *head;
 int n=0;
 FILE *fp;
 void open(){
 if((fp=fopen("yuanshi.txt","r"))==NULL){
 printf("can not open this file\n");
 exit(0);    }
 }
 /*此函数用来读取数据,创建一个链表,head为链表的头指针。*/
 void creat(){
 struct str *p1,*p2;
 int i=1;
 FILE *fp1,*fp2;
 p1=p2=(struct str *) malloc(LEN);
 fp2=fp;
 for(fp1=fp;(fgetc(fp1))!='\n';fp1++,i++);
 fgets(p1->s,i+1,fp2);
 fgets(p1->h,i+1,fp2);
 /*   gets(p1->s);gets(p1->h);   这是我原来用的语句。*/
 while(strcmp(p1->s,"0")!=0){
 n++;
 if(n==1) head=p1;
 else p2->next=p1;
 p2=p1;
 p1=(struct str *)malloc(LEN);
 /*gets(p1->s);gets(p1->h);   这也是。*/
 fp2=fp1;
 for(i=1;(fgetc(fp1))!='\n';fp1++,i++);
 fgets(p1->s,i+1,fp2);
 fgets(p1->h,i+1,fp2);
 }
 p2->next=NULL;
 fclose(fp);
 }
 /*此函数用来对链表按照字母的大小进行排序。*/
 void sort(){
 struct str *p1,*p2,*p;
 struct str *temp;
 int i;
 p=head;
 for(i=1;i<=n;i++){
 p2=p; p1=p->next;
 if(p1!=NULL){
 while(p1!=NULL){
 if(strcmp(p2->s,p1->s)>0)   p2=p1;
 p1=p1->next;
 }
 p1=p->next;
 strcpy(temp->s,p->s); strcpy(temp->h,p->h);
 strcpy(p->s,p2->s); strcpy(p->h,p2->h);
 strcpy(p2->s,temp->s); strcpy(p2->h,temp->h);
 p=p1;
 }
 }
 }
 /*此函数用来输出结果,也就是最后的字典。*/
 void prin(){
 struct str *p=head;
 FILE *fp;
 if((fp=fopen("Edictry.txt","w+"))==NULL)
 printf("Can not open this file\n");
 printf("Now,these sorted words are:\n");
 while(p!=NULL){
 printf("%s\t%s\n",p->s,p->h);
 fprintf(fp,LEN,1,p);
 p=p->next;
 }
 }
 
 main(){      clrscr();
 open();
 creat();
 sort();
 prin();
 free(head);
 }
 ————————————————————————————————————————
 以下是yuanshi.txt的内容及格式:
 self-propelled
 自走式的
 vehicle
 内燃机
 diesel
 柴油
 cargo capacity
 载重量
 pick-up
 小吨位,微型
 tipping bodies
 翻转斗
 dump trucks
 自卸车
 framed
 有架式的
 frameless
 无价的
 carburettor
 化油器
 track
 履带
 trailer
 拖车
 prime mover
 原动机
 power takeoff shaft
 动力输出轴
 tillage
 整地
 discing
 犁地
 row-crop
 行作业
 running gear
 行走系
 crawler
 履带式的
 cross-country
 越野
 traction
 附着力
 under carriage
 纵向的,轴向的
 drive line
 传动系
 dutch
 离合器
 shift gear
 变速,换档
 transmission
 变速器
 brake
 制动器
 hitch bar
 牵引杆
 throttle
 油门
 radiator shutter
 散热四风门
 wind shield wiper
 风挡刮水器
 heater blower
 阻风门
 crank handle
 摇把
 gear shift lever
 变速杆
 dashboard
 仪表盘
 licence plate light
 牌照灯
 hood catch
 机罩搭口
 cowl ventilator
 车头通风口
 magneto grounding switch
 磁石接地开关
 priming pump
 引液泵
 governor booster
 调速加速器
 suction
 吸入
 dog
 挡块,止动销
 cock
 旋塞
 hand primer
 手打油杆
 parking brake lever
 驻车制动拉杆
 ammeter
 电流表
 consumer
 消耗装置
 fuel gauge
 燃油计
 ambient
 周围
 kick back
 往后倒
 oil cooler
 润滑油冷却器
 combustion
 燃烧
 enclosed
 封闭的
 compression ignition engine
 压燃式发动机
 single-row
 直列式
 air-fuel mixture
 可燃混合气
 combustible charge
 易燃充量
 reciprocating
 往复的
 cylinder head
 气缸盖
 rocker arm
 摇臂
 injection pump
 喷油泵
 injector
 喷油器
 the top dead
 上止点
 the bottom dead
 下止点
 engine displacement
 气缸工作容积
 total volume
 总容积
 the clearance volume
 间隙容积
 compression ratio
 压缩比
 engine cycles
 工作循环
 intake stroke
 进气冲程
 compression stroke
 压缩冲程
 exhaust stroke
 排气冲程
 scuffing
 划伤磨损
 premature
 过早的
 rubbing
 摩擦
 timing gear
 正时齿轮
 atomized
 雾化的
 flywheel
 飞轮
 air cleaner
 空气滤清器
 piston
 活塞
 switch on
 接通
 gas tank shut-off cock control handle
 燃油箱的阻塞旋塞控制手柄
 tachometer/speedomter
 速度计
 heater blower and ventilator switch
 热风吹送器和通气器开关
 head light switch
 头灯开关
 decompressor cotrol lever
 减压器控制手柄
 left-hand steering control lever
 左转控制拉杆
 righr-hand steering control lever
 右转控制拉杆
 magneto gounding switch
 磁石接地开关
 engine coolant temperature gauge
 发动机冷却液温度计
 oil pressure warning lamp
 油压警示灯
 torque multiplier oil pressure gauge
 带有扭矩放大器的油压计
 starer motor switch
 启动马达开关
 engine oil pressure gauge
 发动机油压计
 battery switch indicator lamp
 电池开关指示灯
 horn button
 喇叭按钮
 torque multiplier control lever
 扭矩放大器控制拉杆
 fuel pump lever (goternor override)
 燃油泵拉杆
 master clutch pedal
 主离合器踏板
 diver's seat
 司机座
 PTO shifter lever
 动力输出轴的变速杆
 right-hand brake petal lock ratchet
 右边制动踏板止动棘轮
 right-hand brake petal
 右边制动踏板
 left-hand brake petal
 左边制动踏板
 starting gear clutch and diver pinion control lever
 启动离合器和主动齿轮控制拉杆
 gear shift lever
 变速杆
 hydraulic cotrol levers for the right-hand remote control hydraulic cylinders of mounted implements
 装有农具的左右手和主远程控制液压缸的液压控制拉杆
 cylinder head
 气缸盖
 rocker arm
 摇臂
 fuel injector
 喷油门
 exhaust valve
 排气门
 intake valve
 进气门
 cylinder
 气缸
 piston
 活塞
 piston pin
 活塞销
 cunnecting rod
 连杆
 crankcase
 曲轴箱
 crankshaft
 曲轴
 crankshaft timing gear
 凸轮轴的正时齿轮
 camshaft
 凸轮轴
 fuel ingection pump
 喷油泵
 valve lifter(tappet) and push-rod
 气门的推杆和挺杆
 in-line engine structure
 单列式发动机结构
 cylinder-block-and-crank-case unite of monoblock construction
 整体式气缸体曲轴箱
 oil pan(sump)
 油底壳
 timing case
 正时齿轮箱
 valve cover
 气门室罩
 cylinder head cover
 气缸盖罩
 flywheel(bell) housing
 飞轮壳体
 engine rear support
 发动机后支撑
 tractor frame
 拖拉机车架
 cylinder block
 气缸体
 horizontal partition(lower deck)
 水平隔板
 clankcase
 曲轴箱
 clankcase partitions(bulkheads)
 曲轴箱隔板
 camshaft bearing bore
 凸轮轴的轴承孔
 vertical partition
 竖直隔板
 push-rod(tappet) chamber
 挺柱室
 liquid-cooled in-line engine
 水冷单列发动机
 liquid-cooled V-type engine
 水冷V型发动机
 air-cooled engine
 空冷发动机
 push-rod holes
 推杆孔
 water holes
 水道孔
 cylinder head stud holes
 气缸盖螺栓孔
 water passage
 水道
 cylinder line(sleeve)
 气缸衬套
 oil passage
 油道
 crankshaft(main) bearing caps
 曲轴的主轴承盖
 bearing saddle
 轴承座
 rubber sealing ring
 橡胶密封环
 camshaft bearing bore
 凸轮轴轴承孔
 left and right-hand cylinder banks respectively
 左右气缸组
 tappet chamber
 挺柱室
 stud
 螺栓
 air-cooled cylinder barrel
 风冷气缸孔
 cylinder liner bore
 气缸衬套孔
 sealing gasket
 密封垫片
 cylinder dect
 气缸底面
 timing case mounting pad
 正时齿轮箱安装台
 tappet cover and turbo-compressor(supercharger) mounting pad
 挺柱室盖和涡轮压缩机安装台
 intake ports of the third and fourth cylinder
 第三第四气缸的进气道
 valve
 气门
 breather
 通气装置
 exhaust ports of the second and third cylinder
 第二第三气缸的排气道
 valve cover
 气门盖
 water jacket
 水套
 cylinder-block-and-crank-case unit
 气缸体-曲轴箱
 water pump
 水泵
 timing case adaptor plate
 正时齿轮箱结合盘
 engine front support
 发动机的前支撑
 engine support cushion
 发动机的支撑垫片
 engine front support bracket
 发动机的前支撑架
 crankshaft radial lip rubber seals
 曲轴的径向橡胶密封垫片
 oil pan
 油盘
 oil pump
 油泵
 crankshaft
 曲轴
 camshaft
 凸轮轴
 baffle plate
 挡板
 rear adaptor plate
 后结合盘
 metal-asbestos gasket
 金属石棉垫片
 exhaust port of the fourth cylinder
 第四气缸的排气道
 oil-feed pipe to valve mechanism
 配气机构的供油管
 wet cylinder liner
 湿缸套
 illustrating the installation of a cylinder liner in an automobile engine
 汽车发动机的气缸套安装示例
 ail-cooled cylinder
 风冷气缸
 collar
 缸套颈
 top retaining flange
 上定位凸缘
 bottom retaining flange
 下定位凸缘
 rubber sealing ring
 橡胶密封环
 cylinder barrel
 气缸桶
 insert
 护圈
 water jacket
 水套
 sealing gasket
 密封垫片
 0
 0
 --------------由 huoniaolinxi  发表
 
 
 | 
 
| 我是一个呼吸着现在的空气而生活在过去的人
 这样的注定孤独,孤独的身处闹市却犹如置身于荒漠
 我已习惯了孤独,爱上孤独
 他让我看清了自我,还原了自我
 让我再静静的沉思中得到快乐和满足
 再孤独的世界里我一遍又一遍
 不厌其烦的改写着自己的过去
 延伸到现在与未来
 然而那只是泡沫般的美梦
 产生的时刻又伴随着破灭的到来
 在灰飞烟灭的瞬间我看到的是过程的美丽
 而不是结果的悲哀。。。
 
 |  |