| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 674 人关注过本帖
标题:关于一个程序的流程图.,请指教
只看楼主 加入收藏
浪跡天涯㊣
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-10-23
收藏
 问题点数:0 回复次数:3 
关于一个程序的流程图.,请指教

各位大侠可否帮忙写下这个程序的流程图,很急的,在线等~
小弟在这先谢过了
#include<stdio.h>


struct list /*定义结构体*/
{
char name[256]; /*姓名*/
int num; /* 学号*/
int computer; /* 计算机*/
int english; /* 英语*/
int math; /* 数学*/
struct list *next; /* 结构体指针*/
}node;

typedef node *link; /*头指针*/

printf_list(link head) /*显示数据的函数*/
{
link pointer;
pointer=head;
while(pointer!=NULL)
{
printf("number:%d\n",pointer->num);
printf("name:%s\n",pointer->name);
printf("computer:%d\n",pointer->computer);
printf("english:%d\n",pointer->english);
printf("math:%d\n",pointer->math);
pointer=pointer->next;
}
}

link creat_list(link head) /*输入相关数据的函数*/
{
int cnum;
char cname[256];
int ccomputer;
int cenglish;
int cmath;
link pointer,new;
int i;
head=(link)malloc(sizeof(node));
if(head==NULL)
{
printf("memory allocate failure!!\n");
exit(0);
}
else
{
printf("please input number:");
scanf("%d",&cnum);
printf("please input name:");
scanf("%s",&cname);
printf("please input computer:");
scanf("%d",&ccomputer);
printf("please input english:");
scanf("%d",&cenglish);
printf("please input math:");
scanf("%d",&cmath);
head->num=cnum;
for(i=0;i<256;i++)
{
head->name[i]=cname[i];
}
head->computer=ccomputer;
head->english=cenglish;
head->math=cmath;
head->next=NULL;
pointer=head;
while(1)
{
new=(link)malloc(sizeof(node));
if(new==NULL)
{
printf("memory allocate failure!!\n");
exit(0);
}
printf("please input number:");
scanf("%d",&cnum);
if(cnum==0){ break;
}
printf("please input name:");
scanf("%s",cname);
printf("please input computer:");
scanf("%d",&ccomputer);
printf("please input english:");
scanf("%d",&cenglish);
printf("please input math:");
scanf("%d",&cmath);
new->num=cnum;
for(i=0;i<256;i++)
{
new->name[i]=cname[i];
}
new->computer=ccomputer;
new->english=cenglish;
new->math=cmath;
new->next=NULL;
pointer->next=new;
pointer=new;
}
}
return head;
}

search_score(int key1,link head) /*查找成绩的函数*/
{
link pointer;
pointer=head;
while(pointer!=NULL)
{
if(pointer->num==key1)
{
printf("number:%d\n",pointer->num);
printf("name:%s\n",pointer->name);
printf("computer:%d\n",pointer->computer);
printf("english:%d\n",pointer->english);
printf("math:%d\n",pointer->math);
}
pointer=pointer->next;
}
}

link modify_score(link head,int key3) /*修改成绩的函数*/
{
link pointer;
char xname[256];
int xcomputer;
int xenglish;
int xmath;
int choose,i;
pointer=head;
printf("enter 0 exit modefiy\n");
printf("enter 1 modefiy name\n");
printf("enter 2 modefiy computer\n");
printf("enter 3 modefiy english\n");
printf("enter 4 modefiy math\n");
scanf("%d",&choose);
switch(choose)
{
case 1:
printf("please input name:");
scanf("%s",&xname);
break;
case 2:
printf("please input computer:");
scanf("%d",&xcomputer);
break;
case 3:
printf("please input english:");
scanf("%d",&xenglish);
break;
case 4:
printf("please input math:");
scanf("%d",&xmath);
break;
}
while(1)
{
pointer=pointer->next;
if(pointer->num==key3)
{
if(choose==1)
{
for(i=0;i<256;i++)
{
pointer->name[i]=xname[i];
}
break;
}
else if(choose==2)
{
pointer->computer=xcomputer;
break;
}
else if(choose==3)
{
pointer->english=xenglish;
break;
}
else if(choose==4)
{
pointer->math=xmath;
break;
}
}
}
return head;
}

link delete_score(link head,int key2) /*删除成绩的函数*/
{
link pointer;
link back;
pointer=head;
while(1)
{
if(head->num==key2)
{
head=pointer->next;
free(pointer);
break;
}
back=pointer;
pointer=pointer->next;
if(pointer->num==key2)
{
back->next=pointer->next;
free(pointer);
break;
}
}
return head;
}

link insert_score(link head,link new,int key3) /*插入成绩的函数*/
{
link pointer;
pointer=head;
while(1)
{
if(pointer==NULL)
{
new->next=head;
head=new;
break;
}
if(pointer->num==key3)
{
new->next=pointer->next;
pointer->next=new;
break;
}
pointer=pointer->next;
}
return head;
}
aver_score(link head) /*求总的各科平均成绩的函数*/
{
link pointer;
int pcomputer,ppcomputer;
int penglish,ppenglish;
int pmath,ppmath;
int count;
pcomputer=0;
penglish=0;
pmath=0;
count=0;
pointer=head;
while(1)
{
pcomputer=pcomputer+pointer->computer; /*求总的计算机平均成绩*/
penglish=penglish+pointer->english; /*求总的英语平均成绩*/
pmath=pmath+pointer->math; /*求总的数学平均成绩*/
count=++count;
if(pointer->next==NULL)
{
break;
}
pointer=pointer->next;
}
ppcomputer=pcomputer/count;
ppenglish=penglish/count;
ppmath=pmath/count;
printf("computer average score:%d\n",ppcomputer); /*输出计算机平均成绩*/
printf("english average score:%d\n",ppenglish); /*输出英语平均成绩*/
printf("math average score:%d\n",ppmath); /*输出数学平均成绩*/
}

main() /*主函数*/
{
for(;;) /*帮助信息以转向个功能函数*/
{
link head;
link new;
int key;
int keynum;
printf("0>exit the program.\n"); /*退出*/
printf("1>create list.\n"); /*输入数据*/
printf("2>search score.\n"); /*查找数据*/
printf("3>modify score.\n"); /*修改数据*/
printf("4>delete score.\n"); /*删除数据*/
printf("5>add score.\n"); /*增加数据*/
printf("6>average score.\n"); /*平均成绩*/
printf("7>print score.\n"); /*显示所有数据*/
scanf("%d",&key);
switch(key)
{
case 0: exit(0); /*退出函数*/
case 1: head=creat_list(head);
if(head!=NULL)
{
printf_list(head);
}
break;
case 2: printf("please input 0 Exit.\n");
printf("please input number for search:");
scanf("%d",&keynum);
if(keynum==0)
{
break;
}
search_score(keynum,head);
break;
case 3: printf("please input number for modify:");
scanf("%d",&keynum);
head=modify_score(head,keynum);
if(head!=NULL)
{
printf_list(head);
}
break;
case 4: printf("please input 0 exit\n");
printf("please input number for delete:");
scanf("%d",&keynum);
if(keynum==0)
{
break;
}
head=delete_score(head,keynum);
break;
case 5: if(head!=NULL)
{
new=(link)malloc(sizeof(node));
printf("please input number:");
scanf("%d",&new->num);
if(new->num==0)
{
break;
}
printf("please input name:");
scanf("%s",&new->name);
printf("please input computer:");
scanf("%d",&new->computer);
printf("please input english:");
scanf("%d",&new->english);
printf("please input math:");
scanf("%d",&new->math);
printf("please input the data number for insert:");
scanf("%d",&keynum);
head=insert_score(head,new,keynum);
if(head!=NULL)
{
printf_list(head);
}
}
break;
case 6: aver_score(head);
break;
case 7: printf_list(head);
break;
}
}
}

[此贴子已经被作者于2006-10-24 10:45:14编辑过]

搜索更多相关主题的帖子: 流程图 指教 
2006-10-23 22:53
浪跡天涯㊣
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-10-23
收藏
得分:0 

没高手吗?
失望ing

2006-10-24 10:34
shengwumozhe
Rank: 1
等 级:新手上路
帖 子:54
专家分:0
注 册:2006-10-24
收藏
得分:0 

不是没高手,你应该把问题具体化,具体的,哪个环节不会写,那么多行的程序代码让人给你全部画一遍?


自信,微笑^_^
2006-10-24 10:37
浪跡天涯㊣
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-10-23
收藏
得分:0 
就是上面红色的功能函数的流程图,可以分开写哈
2006-10-24 10:46
快速回复:关于一个程序的流程图.,请指教
数据加载中...
 
   



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

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