#include <stdio.h>#include <stdlib.h>int count = 0;struct sell_record{ char name[20]; float income;};void sort(struct sell_record sell[]){ int i, j; struct sell_record temp; for(i = 0; i<count-1; i++) { for(j = i+1; j<count; j++) { if(sell[i].income < sell[j].income ) { come = sell[i].income ; sell[i].income = sell[j].income ; sell[j].income = come ; } } } for(int k = 0; k<count; k++) { printf("%f\n",sell[k].income); }}void writefile(struct sell_record sell[]){ FILE *fp; if((fp = fopen("c:\\c_1.text","wb+"))==NULL) { printf("文件打开错误!"); exit(1); } for(int i=0;i<count;i++) { fwrite(&sell[i],sizeof(struct sell_record),1,fp); } fclose(fp);}void main(){ char ch = 'y'; struct sell_record sell[50]; printf("\t\t北京市交易二手房录入\n"); do{ printf("请输入第%d个卖房人的信息:\n",count+1); printf("输入卖房人的姓名:"); scanf("%s",sell[count].name); printf("输入卖房人的收入:"); scanf("%f",&sell[count].income); count++; printf("是否继续输入(y/n)?\n"); getchar(); scanf("%c",&ch); }while(ch == 'y'||ch == 'Y'); //sort(sell); printf("%s,%f\n",sell[0].name ,sell[0].income ); writefile(sell);}

热心网友

for(int k = 0; k