已知在文件IN.DAT中存有100个产品销售记录,每个产品销售记录由产品代码dm(字

题型:问答题

问题:

已知在文件IN.DAT中存有100个产品销售记录,每个产品销售记录由产品代码dm(字符型4位)、产品名称mc(字符型10位)、单价dj(整型)、数量sl(整型)、金额je(长整型)五部分组成。其中,金额=单价X数量计算。函数ReadDat()读取这100个销售记录并存入结构数组sell中。请编制函数SortDat(),其功能要求如下:按产品名称从小到大进行排列,若产品名称相等,则按金额从小到大进行排列,最终排列结果仍存入结构数组sell中,最后调用函数WriteDat()把结果输出到文件OUT5.DAT中。
注意:部分源程序已给出。请勿改动主函数main()、读数据函数ReadDat()和输出数据函数WriteDat()的内容。
试题程序:
#include<stdio.h>
#include<mem.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
#define MAX 100
typedef struct

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("IN.DAT","r");
for(i=0;i<100;i++)

fgets(str,80,fp);
memcpy(sell[i].dm,str,4);
memcpy(sell[i].me,str+4,10);
memcpy(ch,str+14,4);ch[4]=0;
sell[i].dj=atoi(ch);
memcpy(ch,str+18,5);ch[5]=0;
sell[i].sl=atoi(ch);
sell[i].je=(long)sell[i].dj*sell[i].sl;

fclose(fp);

void WriteDat()

FILE*fp;
int i;
fp=fopen("OUT5.DAT","w");
for(i=0;i<100;i++)

printf("%s%s%4d%5d%5d\n",sell[i].dm,sell
[i].mc,sell[i].dj,sell[i].sl,sell[i].je);
fprintf(fp,"%s%s%4d%5d%5d\n",sell[i].dm,
sell[i].mc,sell[i].dj,sell[i].sl,sell[i].je);

fclose(fp);

考点:计算机等级考试网络技术三级网络技术机试
题型:问答题
阅读理解。
     When the idea of going to Beirut (贝鲁特) first came to my mind in 2001, I thought something was
going wrong with me. I had always thought Beirut was a war-torn (战争创伤的) place with rude and hungry
people running all over. But I was wrong.
     The airport in Beirut was just like any airport you could find in Canada and the United States. Everything
was clean and new. The people there were very helpful and very kind.
     The streets of Beirut were not what I had expected. I thought it would be a terrible place with broken
buildings and things of that kind. Instead I saw a beautiful city with tall buildings and busy streets filled with
laughing people who were very friendly and understanding of my foreign ways.
      I thought that their way of life would be different, their clothes and their food. I was right about one
thing --- their food was different but it was amazing. However, they have different kinds of western foods
and western restaurants. Their clothing is exactly the same. Their language is beautiful and they live a happy
life. English and French are widely spoken. I have visited Beirut four times after that and I plan to go there
again.
Streets People Food Clothing
Beirut in the writer's mind1.______2.______Different Different
Beirut in the writer's eyesBusy3.______4.______5.______
题型:问答题

关节型过敏性紫癜又称()。

A.Vascular purpura

B.allergic purpum

C.Henoch 紫癜

D.schonlein 紫癜

E.Henoch-Schonlein 紫癜

题型:问答题

脊髓空洞症( )

A.自下而上发展的感觉障碍
B.全身感觉障碍
C.四肢末端各种感觉障碍
D.节段性分离性感觉障碍
E.自上而下发展的感觉障碍

题型:问答题

若备选设备有光网络单元(ONU)、光收发器和交换机,为图17-2中A、B、C选择正确的设备。

题型:问答题

根据《合同法》第83条规定,债务人接到转让通知时,债务人对让与人享有到期债权的,债务人可以依据抵销规则向______主张抵销。( )

A.让与人
B.受让人
C.让与人与或受让人
D.让与人和受让人

更多题库