| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 559 人关注过本帖
标题:求助 一C语言课程设计
只看楼主 加入收藏
sufan
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2007-4-5
收藏
 问题点数:0 回复次数:4 
求助 一C语言课程设计
本人17号要上交C语言课程设计,但由于能力有限,希望高手多多帮忙

题目:
学生姓名,卡号.消费时间,金额,消费类型

要求:
1.添加某个学生的某次消费记录
2.删除某个学生的某次消费记录
3.显示某个学生的消费记录
4.查找某个时间段内消费的学生,并按照消费金额的多少进行排序
搜索更多相关主题的帖子: C语言 课程 设计 
2007-05-15 19:21
sufan
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2007-4-5
收藏
得分:0 
回复:(sufan)求助 一C语言课程设计
   现在只是最后一个要求做不出来啊!
2007-05-16 13:14
leeco
Rank: 4
等 级:贵宾
威 望:10
帖 子:1029
专家分:177
注 册:2007-5-10
收藏
得分:0 
可以用数据库吗?
2007-05-16 15:17
sufan
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2007-4-5
收藏
得分:0 
我没有学数据库,有谁能帮忙呢?

小弟实在是做不出来了
2007-05-16 17:05
sufan
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2007-4-5
收藏
得分:0 

我现在基本上已经把前边的弄好了 就差最后一个要求的了


#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>

static int number=0;

struct time{
int month;
int day;
};

struct student{
char name[10];
float xiaofei[10];
char cnumber[20];
struct time stime;
char leixing[10];
struct student* next;
};

struct student* addst(struct student* s_he)
{

struct student* s_st=NULL;
struct student* s_ne=NULL;
if(s_he!=NULL)
for(s_ne=s_he;s_ne->next!=NULL;s_ne=s_ne->next);
do{
s_st=(struct student*)malloc(sizeof(struct student));
printf("\nPlease putin name xiaofei cnumber time leixing:");
scanf("%s %s %s %d %d %s",s_st->name,s_st->xiaofei,s_st->cnumber,s_st->stime.month,s_st->stime.day, s_st->leixing);
if(number==0) s_he=s_st;
else s_ne->next=s_st;
s_ne=s_st;
number++;
printf("\nDo you continue?(y/n)\n");
}while(getch()=='y');
s_ne->next=NULL;
return s_he;
}


void savest(struct student* s_st)
{
char str[30];
FILE *f_1;
int num=0;
printf("\nFILE NAME:");
scanf("%s",str);
f_1=fopen(str,"w");
for(;num<number;num++,s_st=s_st->next)
fprintf(f_1,"ID:%d\tNAME:%s\tXIAOFEI:%s\tCNUMBER:%s\tTIME:%d %d\tLEIXING:%s\n",num,s_st->name,s_st->xiaofei,s_st->cnumber,s_st->stime.month,s_st->stime.day,s_st->leixing);
fclose(f_1);
}


struct student* deletest(struct student* s_he)
{
struct student* s_1=s_he;
struct student* s_2=s_he;
struct student* s_3=s_he;
int i;
int idnum=1;
do{
printf("\nID:");
scanf("%d",&idnum);
}while(idnum<0||idnum>=number);
if(idnum==1){
s_he=s_he->next;
free(s_1);
}
else{
for(i=0;i<idnum-1;i++)
s_1=s_1->next;
s_2=s_1->next;
if(idnum==number-1){
s_1->next=NULL;
free(s_2);
}
else{
s_3=s_2->next;
s_1->next=s_3;
free(s_2);
}
}
number--;
return s_he;
}


void displayst(struct student* s_st)
{
char str[7];
int i=0;
printf("\nNAME:");
scanf("%s",str);
for(;s_st!=NULL;s_st=s_st->next,i++)
if(strcmp(str,s_st->name)==0){
printf("ID:%d\tNAME:%s\tXIAOFEI:%s\tCNUMBER:%s\StTIME:%d %d\tLEIXING:%s\n",i,s_st->name,s_st->xiaofei,s_st->cnumber,s_st->stime.month,s_st->stime.day,s_st->leixing);
}
}

void changest(struct student* s_st)
{
int idnum=1;
int i=0;
do{
printf("\nID:");
scanf("%d",&idnum);
}while(idnum<0||idnum>=number);
for(;i<idnum;i++,s_st=s_st->next);
printf("NAME:%s\tXIAOFEI:%s\tCNUMBER:%s\tSTIME:%d %d\tLEIXING:%s\n",s_st->name,s_st->xiaofei,s_st->cnumber,s_st->stime.month,s_st->stime.day,s_st->leixing);
printf("\nPlease putin name xiaofei cnumber time leixing:");
scanf("%s,%s,%s,%d %d,%s",s_st->name,s_st->xiaofei,s_st->cnumber,s_st->stime.month,s_st->stime.day,s_st->leixing);
printf("NAME:%s\tXIAOFEI:%s\tCNUMBER:%s\tSTIME:%d %d\tleixing:%s\n",s_st->name,s_st->xiaofei,s_st->cnumber,s_st->stime.month,s_st->stime.day,s_st->leixing);
}


void paixust(struct student* s_st)
{
struct time str,endt;
int i=0;
printf("\n the start time:");
scanf("%d %d",&str.month,&str.day);
printf("\n the end time :");
scanf("%d %d",&endt.month,&endt.day);
for(;s_st!=NULL;s_st=s_st->next,i++)
if (str.month*31+str.day<= s_st->stime.month*31+s_st->stime.day &&s_st->stime.month*31+s_st->stime.day <=endt.month*31+endt.day){
printf("ID:%d\tNAME:%s\tXIAOFEI:%s\tCNUMBER:%s\tSTIME:%d %d\tLEIXING:%s\n",i,s_st->name,s_st->xiaofei,s_st->cnumber,s_st->stime.month,s_st->stime.day,s_st->leixing);
}
}


main()
{
struct student* s_he=NULL;
do{
printf("**************************************************\n");
printf("%dperson joined\n",number);
printf("1.add\n2.detele\n3.display\n4.change\n5.save\n6.paixu\n7.exit\n");
printf("**************************************************\n");
switch (getch()){
case '1':
s_he=addst(s_he);
break;
case '2':
if(number>0)
s_he=deletest(s_he);
break;
case '3':
if(number>0)
displayst(s_he);
break;
case '4':
if(number>0)
changest(s_he);
break;
case '5':
if(number>0)
savest(s_he);
break;
case'6':
if(number>0)
paixust(s_he);
break;
case '7':
exit(0);
}
}while(1);
}


2007-05-16 18:50
快速回复:求助 一C语言课程设计
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.054528 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved