黑马程序员技术交流社区
标题: C语言流程图 [打印本页]
作者: 剑气近 时间: 2014-6-18 23:40
标题: C语言流程图
下面程序的流程图怎么画?我在下面画了一个样图。若是有什么不足之处,请指出
#include<stdio.h>
#include<stdlib.h>
#define N 1024
typedef struct node
{
int sno;/*这里分别是学号(便于最后列表时统计),四门课的分数,总分,平均分*/
int course1;
int course2;
int course3;
int course4;
int aver;
}student;
void main()
{
int i,j,number;
int total1,total2,total3,total4;
total1=total2=total3=total4=0;/*total指的是四门课程的平均分*/
student st[N],temp;
printf("Please input the student's number:");/*确定学生人数*/
scanf("%d",&number);
if(number>1024)
{
printf("The number is too large!\n");
exit(0);
}
for(i=0;i<number;i++)/*进行成绩输入*/
{
printf("Please input the %dth student's sno:",i+1);
scanf("%d",&st.sno);
printf("Please input the %d's student's course1:",st.sno);
scanf("%d",&st.course1);
printf("Please input the %d's student's course2:",st.sno);
scanf("%d",&st.course2);
printf("Please input the %d's student's course3:",st.sno);
scanf("%d",&st.course3);
printf("Please input the %d's student's course4:",st.sno);
scanf("%d",&st.course4);
st.aver=(st.course1+st.course2+st.course3+st.course4)/4;
}
for(i=0;i<number;i++)/*输出每个学生的平均分*/
printf("The %d's student's aver-score is:%d\n",st.sno,st.aver);
for(i=0;i<number;i++)/*输出每科目平均分*/
{
total1+=st.course1;
total2+=st.course2;
total3+=st.course3;
total4+=st.course4;
}
total1/=number;
total2/=number;
total3/=number;
total4/=number;
printf("The averscore of course1 is:%d\n",total1);
printf("The averscore of course2 is:%d\n",total2);
printf("The averscore of course3 is:%d\n",total3);
printf("The averscore of course4 is:%d\n",total4);
for(i=0;i<number-1;i++)/*进行冒泡排序*/
for(j=i+1;j<number;j++)
if(st.aver<st[j].aver)
{
temp=st;
st=st[j];
st[j]=temp;
}
printf("The list of the student's course:\n");
printf("==========\n");/*列表公布成绩*/
for(i=0;i<number;i++)
{
printf("%d.",i+1);
printf("%dth student:%d\n",st.sno,st.aver);
}
}
我使用的工具是Microsoft Visio,这个工具很好画流程图,麻烦帮我看看正确不...
-
图片1.png
(49.11 KB, 下载次数: 84)
作者: chain 时间: 2014-6-19 17:34
用N-S画出来简单些
作者: tansheng521006 时间: 2014-6-19 18:43
没啥问题,但是为啥代码后面全变成斜体了?看得好累啊,而且你的代码容错性不好吧,万一用户输入数据时,输入了空格,咋办?直接重来?
作者: 剑气近 时间: 2014-6-19 20:54
我有空试试N-S哈
作者: 剑气近 时间: 2014-6-19 20:55
sorry 从文档复制的好像格式有些问题就成这样了 确实程序还不够严谨
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) |
黑马程序员IT技术论坛 X3.2 |