已知在文件IN3.DAT中存有100个产品销售记录,每个产品销售记录由产品代码dm(字符型4位)、产品名称mc(字符型10位)、单价dj(整型)、数量sl(整型)、金额je(长整型)五部分组成。其中:金额=单价×数量。函数ReadDat()的功能是读取这 100个销售记录并存入结构数组sell中。请编制函数SortDat(),其功能要求:按产品代码从大到小进行排列,若产品代码相同,则:按金额从大到小进行排列,最终排列结果仍存入结构数组sell中,最后调用函数WriteDat()把结果输出到文件OUT3.DAT中。 注意:部分源程序已给出。请勿改动主函数main()、读数据函数ReadDat()和输出数据函数WriteDat()的内容。 【试题程序】 #include <stdio.h> #include <memory.h> #include <string.h> #include <conio.h> #include <stdlib.h> #define MAX 100 typedef struet char dm[5]; /*产品代码*/ char mc[11]; /*产品名称*/ int dj; /*单价*/ int sl; /*数量*/ long je; /*金额*/ PRO; PRO sell[MAX]; void ReadDat(); void WriteDat() void SortDat() void main) memset(sell,0,sizeof(sell)); ReadDat(); SortDat(); WriteDat(); void ReadDat() FILE *fp; char str[80],ch[11]; int i; fp=fopen("IN3.DAT","r"); for(i=0;i<100;i++) fgets(str,80,fp); memcpy(sell [i] .dm, str,4); memcpy(sell [i] .mc,str+4,10); memcpy(ch, str+14, 4); ch[4]=0; sell [i] .dj=atoi(ch); memcpy(ch,str+18,5);ch[5]=0; selt [i] .sl=atoi(ch); sell [i] .je=(long)sell [i] .dj*sell [i] .sl; fclose(fp); void WriteDat(void) FILE *fp; int i; fp=fopen("OUT3.DAT","w"); for(i=0;i<100;i++) fprintf(fp,"%s %s %4d %5d %101d\n",sell [i] .dm, sell [i] .mc,sell [i] .dj,sell [i] .sl, sell [i] .je); fclose(fp);
第三节 短文理解 2 阅读下列短文,从[A]、[B]、[C]三个选项中选择一个正确答案。 Singapore(新加坡) is the name of an island on the south of Malaya. It is also the name of the cit on the south side of this island. Singapore City is one of the world’s greatest ports. Through it pass goods from all around the world. On most of the island the climate is hot and wet. Fruits, vegetables, and rubber(橡胶) are grown wherever land can be farmed. Malaya is just above Singapore on the map. It is an important shipping center. Much of the rubber that is used in the world is from Malaya. Thick jungles (丛林) cover much of the country. On the little land they can farm, the people raise mostly rice. India is on the west of Burma(缅甸). It is the seventh largest country in the world. And it has more people than any other country except China. India has deserts(沙漠), jungles, plains and mountains. People in India speak about one hundred and eighty languages. On their farms Indians grow wheat, vegetables, rice, and other foods, but they are not able to grow enough food to feed everyone. Which is the seventh largest country in the world