四川高考状元辱骂同胞:跪求用C语言解决这个问题

来源:百度文库 编辑:神马品牌网 时间:2024/05/06 05:07:34
跪求答案。。学长或学姐帮帮忙。。女朋友考我,做不出来就分手的。。。。
帮偶做出来了,我请客必胜客。。说话算话。。。。
二个题做出一个就可以了。。。

要求用C语言写出下面程序。。。

① 门票收费系统

基本功能:1.统计每天公园里的收费情况2.可以自动计算应收费用,一次购票人数>=30人,票价4元,<30人票价5元,可以实现最优价选择(比如,28个人,按5元买28张,不如按4元买30张)。3.可以查询一月里任一天的收费情况。

附加功能:1.可查询一月里收费最好和最差的一天的情况。2.总结每天里入园最旺的时段,综合一个月的情况得出此月的入园最旺时段。

② 学生成绩处理系统

基本功能:1.纪录学生的各科成绩。2.计算总分,平均分,按平均分给学生排序。3.可查询任一学生的成绩情况。

附加功能:1. 可查询任一学生的排名情况。2.可查询排名前十的学生。3.可查询平均分达到优秀(>=85)、良好(>=75)、及格(>=60)、不及格(<60)的学生的情况。4.可查询有3门功课以上不及格的学生的情况。

至少要完成基本功能,可选择附加功能中的一个或几个实现,或可以根据自己的想法实现其他上面没有注明的功能。

具体实现的格式、方式,输入和显示格式,学生课程的多少、科类,数据存储形式等所有细
节,由你自行决定,任意发挥。

/*怎么可能这样提问呢,你女朋友要分手??哈哈,帮你一把,必胜客,算了吧。最喜欢帮兄弟了*/
/*头文件*/
#include"stdio.h"
#include"bios.h"
void input();/*输入*/
void display();/*显示*/
void stat1();/*排序*/
void dele();/*逻辑删除*/
char f;
/*结构定义*/
struct stu
{
int no;
char name[10];
int math;
int eng;
int com;
int flag;
};
/*主函数*/
void main()
{
char x;
int i;
for(;;)/*菜单的显示*/
{
printf("\n\n\n\t\t\t1.input:");
printf("\n\n\t\t\t2.display:");
printf("\n\n\t\t\t3.arrange:");
printf("\n\n\t\t\t4.delete:");
printf("\n\t\n\t\t\t0.exit:");
printf("\n\n\n\t\t\tchoice:");
x=getch();
printf("\n");
/*离开*/
if(x=='0')
{
printf("\n\t\t\tbye!\n");
break;
}
/*输入*/
if(x=='1')
{
input();
}
/*显示*/
if(x=='2')
{
display();
}
/*排序*/
if(x=='3')
{
stat1();
}
/*删除*/
if(x=='4')
{
dele();
}
}
}
/*输入函数*/
void input()
{
FILE *fp;
struct stu stu1;
char y,filename[30];
/*两种输入,1。打开一个新的文件 2。在原有的文件上输入*/
printf("\n\n\t\t\t1.new\n");
printf("\t\t\t 2.old\n");
printf("\t\t\t ");
y=getch();
/*在旧的文件上输入*/
if(y=='2')
{
printf("\n\t\t\t The input name:");
printf("\t\t\t ");
scanf("%s",filename);
fp=fopen(filename,"ab");
if(fp==NULL)
{
printf("\t\t\tfile open error!!");
exit();
}
printf("\n\n\t\t\tplease input 0 exit");
while(1)
{
printf("\n\t\t\tnumber:");
scanf("%d",&stu1.no);
if(stu1.no==0)
break;
printf("\t\t\tname:");
scanf("%s",&stu1.name);
printf("\t\t\tmath:");
scanf("%d",&stu1.math);
printf("\t\t\tenglish:");
scanf("%d",&stu1.eng);
printf("\t\t\tcomputer:");
scanf("%d",&stu1.com);
stu1.flag=0;
fwrite(&stu1,sizeof(stu1),1,fp);
}
}
/*在新文件输入*/
if(y=='1')
{
printf("\n\t\t\tfound name\n");
printf("\t\t\t ");
scanf("%s",filename);
fp=fopen(filename,"wb");
if(fp==NULL)
{
printf("\t\t\tfile open error!!!");
exit();
}
/*提示:在学号处输入0离开*/
printf("\n\n\t\t\tno input 0 exit!!");
/*输入内容*/
while(1)
{
printf("\n\t\t\tno:");
scanf("%d",&stu1.no);
if(stu1.no==0)
break;
printf("\t\t\tname:");
scanf("%s",&stu1.name);
printf("\t\t\tmath:");
scanf("%d",&stu1.math);
printf("\t\t\tenglish:");
scanf("%d",&stu1.eng);
printf("\t\t\tcomputer:");
scanf("%d",&stu1.com);
stu1.flag=0;
/*写入文件*/
fwrite(&stu1,sizeof(stu1),1,fp);
}
}
/*关闭文件*/
fclose(fp);
}

/*显示的函数*/
void display()
{
FILE *fp;
struct stu stu1;
char filename[30],f;
printf("\n\t\t\topen list name");
printf("\t\t\t ");
while(1)
{
if(bioskey(1)!=0)
{
bioskey(0);
}
if(bioskey(1)==0)
break;
}
scanf("%s",filename);
f=filename;
fp=fopen(filename,"rb");
if(fp==NULL)
{
printf("\t\t\tfile open error");
return;
}
/*表头部分*/
printf("\n\t\t\t student");
printf("\n\t\t\t =====================");
printf("\n\t\t\t+------+-----+-----+-----+-------+");
printf("\n\t\t\t|no |name |math |engl |comput |");
printf("\n\t\t\t+------+-----+-----+-----+-------+");
while(!feof(fp))
{
stu1.no=0;
fread(&stu1,sizeof(stu1),1,fp);
/* 1 代表读出一个数据 */
if(stu1.no==0)
break;
if(stu1.flag==0)
{
printf("\n\t\t\t|%-4d |%-5s| %3d| %3d| %4d |",stu1.no,stu1.name,stu1.math,stu1.eng,stu1.com);
printf("\n\t\t\t+------+-----+-----+-----+-------+");
}
}
fclose(fp);
getch();
}

/*排序函数*/
void stat1()
{
FILE *fp;
struct stu stu1;
char filename[30];
int total;
float avarge;
printf("\n\t\t\topen name");
printf("\t\t\t ");
while(1)
{
if(bioskey(1)!=0)
{
bioskey(0);
}
if(bioskey(1)==0)
break;
}
scanf("%s",filename);
fp=fopen(filename,"rb");
if(fp==NULL)
{
printf("\t\t\terror");
return;
}
printf("\n\t\t student ");
printf("\n\t\t =====================");
printf("\n\t\t+------+-----+-----+-----+-------+-----+------+");
printf("\n\t\t|no |name |math |eng |comput |Amark|averag|");
printf("\n\t\t+------+-----+-----+-----+-------+-----+------+");

while(!feof(fp))
{
fread(&stu1,sizeof(stu1),1,fp);
total=stu1.math+stu1.eng+stu1.com;
avarge=(float)total/3;
printf("\n\t\t|%-4d |%-5s| %3d| %3d| %4d | %4d| %5.2f|",stu1.no,stu1.name,stu1.math,stu1.eng,stu1.com,total,avarge);
printf("\n\t\t+------+-----+-----+-----+-------+-----+------+");
}
fclose(fp);

}

/*删除函数*/
void dele()
{
int x;
long y;
FILE *fp;
struct stu stu1;
display();
printf("\n\t\t\tdelete number");
printf("\n\t\t\t ");
scanf("%d",&x);
fp=fopen(f,"rb+");
while(!feof(fp))
{
stu1.no=0;
y=ftell(fp);
fread(&stu1,sizeof(stu1),1,fp);
if(stu1.no==0) break;
if(stu1.no==x)
{
stu1.flag=1;
fseek(fp,y,SEEK_SET);
fwrite(&stu1,sizeof(stu1),1,fp);
}
}

}

这玩意没半天搞不来.