c语言一个大程序,用基本语句,100句左右

c语言一个大程序,用基本语句,100句左右,第1张

# include "stdio.h"

# include "stdlib.h"

# include "string.h"

# define NULL 0

struct xiangcun

{

char num[4]//乡村的编号

char name[20] //村名

int people //总人数

int relieve//救济人数

float amount //救济总金袜链和额

struct xiangcun *next

}

struct jiating

{

char num[10] //乡村编号

char candidate[20] //身份z号码

char fname[20]//户主名字

char sex[2] //性别

int fpeople //家庭人数

float insert //年收入

int time //接受救助次数

struct jiating * next

}

struct out

{

char candidate[20]//户主身份z号码

char goodsname[20] //商品名字

char date[15]//发放日期

char unit[10] //单位

float price //单价

int count//发放数量

float money /唤正/金额

struct out *next

}

struct xiangcun *h1,*tail1

struct jiating *h2,*tail2

struct out *h3,*tail3

struct xiangcun * rebuilt1() //构建乡村链表

{

int n1=0

struct xiangcun *p1,*p2,*head

p1=p2=(struct xiangcun *)malloc(sizeof(struct xiangcun))

printf("\n\n\n\告盯n\n\n 请输入以下信息:\n 乡村的编号:\n 村名:\n 总人数:\n 救济人数:\n 就系总金额:\n")

scanf("%s%s%d%d%f",p1->num,p1->name,&p1->people,&p1->relieve,&p1->amount)

while(strcmp(p1->num,"0")!=0)

{

n1++

if(n1==1)

h1=p1

else

p2->next=p1

p2=p1

p1=(struct xiangcun *)malloc(sizeof(struct xiangcun))

scanf("%s%s%d%d%f",p1->num,p1->name,&p1->people,&p1->relieve,&p1->amount)

}

p2->next=NULL

return h1

}

struct jiating * rebuilt2() //构建家庭信息链表

{

int n2=0

struct jiating *p1,*p2,*head

p1=p2=(struct jiating *)malloc(sizeof(struct jiating))

printf("\n\n\n\n\n\n 请输入以下信息:\n乡村名字: \n户主身份z号码: \n 户主名字:\n 户主性别:\n 家庭人数:\n 年收入:\n 接受救助的次数:\n")

scanf("%s%s%s%s%d%f%d",p1->num,p1->candidate,p1->fname,p1->sex,&p1->fpeople,&p1->insert,&p1->time)

while(strcmp(p1->candidate,"0")!=0)

{

n2++

if(n2==1)

h2=p1

else

p2->next=p1

p2=p1

p1=(struct jiating *)malloc(sizeof(struct jiating))

scanf("%s%s%s%s%d%f%d",p1->num,p1->candidate,p1->fname,p1->sex,&p1->fpeople,&p1->insert,&p1->time)

}

p2->next=NULL

return h2

}

struct out * rebuilt3() //构建物资信息链表

{

struct out *p1, *p2,*head

int n3=0

p1=p2=(struct out *)malloc(sizeof(struct out))

printf("\n\n\n\n\n\n 请输入以下信息:\n 户主身份z号码:\n 商品名字:\n 发放日期:\n 单位:\n 单价:\n 发放数量:\n 金额:\n")

scanf("%s%s%s%s%f%d%f",p1->candidate,p1->goodsname,p1->date,p1->unit,&p1->price,&p1->count,&p1->money)

while(strcmp(p1->candidate,"0")!=0)

{

n3++

if(n3==1)

h3=p1

else

p2->next=p1

p2=p1

p1=(struct out *)malloc(sizeof(struct out))

scanf("%s%s%s%s%f%d%f",p1->candidate,p1->goodsname,p1->date,p1->unit,&p1->price,&p1->count,&p1->money)

}

p2->next=NULL

return h3

}

int change1(xiangcun *head1,char *num) //对乡村信息的修改

{

struct xiangcun *p

p=head1->next

printf("\n\n\n\n\n\n")

while(1)

{

if(p==NULL)

{

return 1

}

if(strstr(p->num,num))

{

printf(" 请重新输入要修改乡村的各项:")

scanf("%s%s%d%d%d",p->num,p->name,&p->people,&p->relieve,&p->amount)

return 1

}

p=p->next

}

}

int change2(jiating *head2,char *num) //对家庭信息的修改

{

struct jiating *p

p=head2->next

printf("\n\n\n\n\n\n")

while(1)

{

if(p==NULL)

{

return 1

}

if(strstr(p->fname,num))

{

printf(" 请重新输入要修改家庭的各项:")

scanf("%s%s%s%s%d%f%d",p->num,p->candidate,p->fname,p->sex,&p->fpeople,&p->insert,&p->time)

return 1

}

p=p->next

}

}

int change3(out *head3,char *name) //对物资信息的修改

{

struct out *p

p=head3->next

printf("\n\n\n\n\n\n")

while(1)

{

if(p==NULL)

{

return 1

}

if(strstr(p->goodsname,name))

{

printf(" 请重新输入要修改物资的各项:")

scanf("%s%s%s%s%f%d%f",p->candidate,p->goodsname,p->date,p->unit,&p->price,&p->count,&p->money)

return 1

}

p=p->next

}

}

void Csearch(xiangcun* head1) /* 查询全部乡村中每个村的救济总户数*/

{

struct xiangcun *p

p=head1->next

printf("\n\n\n\n\n\n")

if(p==NULL)

{

printf(" 全乡没有被救济的人!\n")

return

}

while(p!=NULL)

{

printf(" %s救济人数为:%d\n",p->name,p->relieve)

p=p->next

}

return

}

int Esearch(xiangcun * head1,char *name) /*查询全部乡村中某个村的村救济总金额*/

{

struct xiangcun *p

p=head1->next

while(1)

{

if(p==NULL)

{

return 0

}

if(strstr(p->name,name))

{

printf("\n\n\n\n\n\n %s的受救济总金额是:%g\n",p->name,p->amount)

return 1

}

p=p->next

}

}

int Fsearch(jiating* head2,char * name) /*查询某救济户 (如:张三)基本信息*/

{

struct jiating *p

p=head2->next

while(1)

{

if(p==NULL)

{

return 0

}

if(strstr(p->fname,name))

{

printf("\n\n\n\n\n\n 户主的乡村编号:%s\n 户主的身份z号码:%s\n",p->num,p->candidate)

printf(" 户主名字是:%s\n 户主性别是:%s\n",p->fname,p->sex)

printf(" 家庭人数:%d\n 年收入:%g\n /接受救助次数:d\n",p->fpeople,p->insert,p->time)

return 1

}

p=p->next

}

}int frelieve(jiating *head2,out *head3,char * name)/*查询某救济户 (如:张三)救济户物资发放的全部信息*/

{

struct jiating * p

p=head2->next

while(1)

{

if(p==NULL)

{

return 0

}

if(strstr(p->fname,name))

{

struct out *p1

p1=head3->next

printf("\n\n\n\n\n\n %s的物资信息:\n",p->fname)

while(1)

{

if(p1==NULL)

{

return 1

}

if(strstr(p->candidate,p1->candidate))

{

printf("物资名字:%s\n发放日期:%s\n物资的量的单位:%s\n",p1->goodsname,p1->date,p1->unit)

printf("物资单价:%g\n 发放数量:%d\n发放金额:%g\n",p1->price,p1->count,p1->money)

}

p1=p1->next

}

}

p=p->next

}

}

int Relieve(jiating * head2,out *head3,char * name,char *name2)/*查询某救济户 (如:张三)是否发放了某种救济物资 (如:矿泉水)的信息*/

{

struct jiating * p

p=head2->next

while(1)

{

if(p==NULL)

{

return 0

}

if(strstr(p->fname,name))

{

out *p1

p1=head3->next

while (1)

{

if(strstr(p->candidate,p1->candidate)&&strstr(p1->goodsname,name2))

{

return 1

}

p1=p1->next

if(p1==NULL)

{

return 0

}

}

}

p=p->next

}

}

void tprint(xiangcun * head1)/*统计并输出全乡的人口总数、救济总户数、救济总金额*/

{

int peo_sum=0,re_sum=0

float re_cost=0

xiangcun *p=h1

while(p!=NULL)

{

peo_sum+=p->people

re_sum+=p->relieve

re_cost+=p->amount

p=p->next

}

printf("\n\n\n\n\n\n 人口总数:%d\n 救济总户数:%d\n救济总金额:%g\n",peo_sum,re_sum,re_cost)

}

#include<stdio.h>

#include<malloc.h>

#include<string.h>

#include<stdlib.h>

#define NULL 0

#define LEN sizeof(struct student)

struct student

{

int num

char name[10]

int score

struct student *next

}

int n

struct student *creat()

{

struct student *head

struct student *p1,*p2

p1=p2=(struct student *)malloc(LEN)

printf("请输入数据:\n"悄冲)

printf("-学号---姓名---成绩-\n")

scanf("%d%s%d",&p1->num,p1->name,&p1->score)

head=NULL

n=0

while(p1->num!=NULL)

{

n=n+1

if(n==1) head=p1

else p2->next=p1

p2=p1

p1=(struct student *)malloc(LEN)

scanf("%d%s%d",&p1->num,p1->name,&p1->score)

}

p2->穗洞next=NULL

return(head)

}

void print(struct student *head)

{

struct student *p

p=head

if(head!=NULL)

{

printf("-学号---姓名---成绩-\n")

while(p!=NULL)

{

printf("%d %s%d\n",p->num,p->name,p->score)

p=p->next

}

}

else printf("没有数据 !\n")

}

struct student *del(int num,struct student *head)

{

int a=0

struct student *p1,*p2

do

{

p1=head

if(head==NULL)

{

printf("没有数据 !\n")

goto end

}

while(p1->num!=num&&p1->next!=NULL)

{

p2=p1p1=p1->next

}

if(p1->num==num)

{

if(p1==head) head=p1->next

else p2->next=p1->next

printf("启族歼删除记录学号为N0.%d\n",num)

n=n-1

a++

}

}while(p1->next!=NULL)

if(a==0)

printf("学号未找到 !\n")

end:

return(head)

}

struct student *add(int num,char name[],int score,struct student *head)

{

struct student *p0,*p1,*p2

p0=(struct student *)malloc(LEN)

p0->num=num,strcpy(p0->name,name),p0->score=score

p1=head

if(num==0)

return(head)

if(head==NULL)

{

head=p0

p0->next=NULL

}

while(p0->num>p1->num&&p1->next!=NULL)

{

p2=p1

p1=p1->next

}

if(p0->num<=p1->num)

{

if(p1==head) head=p0

else p2->next=p0

p0->next=p1

}

else

{

p1->next=p0

p0->next=NULL

}

printf("增加记录学号为:%d\n",num)

n=n+1

return(head)

}

void num(struct student *head)

{

int num,a=0

struct student *p

printf("------请输入 \"0\" 结束输入--------\n")

do

{

p=head

printf("请输入要查找的学号:")

scanf("%d",&num)

if(num!=0)

printf("-学号---姓名---成绩-\n")

while(p!=NULL)

{

if(p->num==num)

{

printf("%d %s %d\n",p->num,p->name,p->score)

a++

}

p=p->next

}

if(a==0&num!=0)

printf("学号没找到!\n")

a=0

}while(num!=0)

system("cls")

}

void name(struct student *head)

{

char name[10],a=0

struct student *p

printf("------请输入 \"0\" 结束输入------\n")

do

{

p=head

printf("请输入要查找的名字:")

scanf("%s",name)

if(name[0]!='0')

printf("-学号---姓名---成绩-\n")

while(p!=NULL)

{

if(strcmp(p->name,name)==0)

{

printf("%d %s %d\n",p->num,p->name,p->score)

a++

}

p=p->next

}

if(a==0&&name[0]!='0')

printf("名字未找到 !\n")

a=0

}while(name[0]!='0')

system("cls")

}

void search(struct student *head)

{

int a

struct student *p

p=head

do

{

printf("1.按学号查找\n2.按名字查找\n3.退出\n")

scanf("%d",&a)

system("cls")

switch(a)

{

case 1:num(p)break

case 2:name(p)break

}

}while(a!=3)

}

struct student *sort(struct student *head)

{

struct student *p1,*p2

int i,j

int num0,score0

char string[10]

for(i=0i<n-1i++)

{

p1=head

for(j=n-1j>0j--)

while(p1->next!=NULL)

{

p2=p1p1=p1->next

if(p2->score>p1->score)

{

num0=p1->num

p1->num=p2->num

p2->num=num0

strcpy(string,p1->name)

strcpy(p1->name,p2->name)

strcpy(p2->name,string)

score0=p1->score

p1->score=p2->score

p2->score=score0

}

}

}

return(head)

}

void main()

{

struct student *head=NULL

int num,score,a

char name[10]

do

{

printf("1.创建记录\n2.删除记录\n3.增加记录\n4.查找记录\n5按成绩排序\n6.显示当前记录\n7.退出\n")

scanf("%d",&a)

system("cls")

switch(a)

{

case 1:printf("------请输入 \"0 0 0\" 结束输入------\n")head=creat()print(head)getch()system("cls")break

case 2:printf("------请输入 \"0\" 结束输入--------\n")do{printf("请输入要删除记录的学号:")scanf("%d",&num)head=del(num,head)print(head)}while(num!=0)system("cls")break

case 3:printf("------请输入 \"0 0 0\" 结束输入------\n")do{printf("请输入要增加的记录数据:\n")printf("-学号---姓名---成绩-\n")scanf("%d%s%d",&num,name,&score)head=add(num,name,score,head)print(head)}while(num!=0)system("cls")break

case 4:search(head)break

case 5:head=sort(head)print(head)getch()system("cls")break

case 6:print(head)getch()system("cls")break

}

}while(a!=7)

以前C语言作业课程设计,希望认真仔细看后反复自己思考,这个只是参考!C语言程序设计大作业

1题目:学生信息管理系统

2 程序要求:

(1)学生信息录入功能

1)用户从键盘输入每个学生的信息:学号、姓名、性别、数学、英语、政治、语文四门课成绩。

2)可插入一个或多个学生信息到当前编辑的班级数据中。

(2)文件保存功能

1)学生信息每一班存为一个数据文件,数据文件可在程序中打开、编辑和重新保存;

2)用户输入学生信息可随时保存数据文件。

(3)文件打开功能

1)程序只能对当前打开的数据文件进行编辑。

(4)查询功能

1)浏览所有学生信息;

2)按学号查询学生信息;

3)按姓名查询学生信息;

4) 查询一个班总成绩和平均成绩

5) 查询一个班某一门课总成绩和平均成绩

6)查询某一门课分数段(<60,60-69,70-79,80-89,>90)学生数。

(5)报表输出功能

1) 按学号输出一个班学生信息:学号、姓名、性别、数学、英语、政治、语文成绩、总成绩,到屏幕和文件。

2) 按总成绩输出从高到低输出学号、姓名信息。

注:以上功能以菜单形式供用户使用,并有一定的容错功能。

3 开发语言环境:

Macrosoft VC++6.0或Turbo C2.0

4 数据结构:

数组或链表

5 程序源代码要求:

(1)函数名、变量名采用英文缩写,使用匈牙利命名法进行自说明;

(2)源代码的书写采用递进格式;

(3)程序行和程序段须有注释。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/8268931.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-14
下一篇 2023-04-14

发表评论

登录后才能评论

评论列表(0条)

保存