平均分老是算不出来
#include "stdio.h"#define N 2
struct a
{
int no;
char name[15];
int c;
int Java;
int total;
float ave;
};
float ave(int,int);
struct a ave(struct a);
void main ()
{
struct a x[N];
int i,total=0;
for (i=0;i<N;i++)
{
printf ("第%d学生:\n",i+1);
printf ("输入学号:");
scanf ("%d",&x[i].no);
printf ("输入学生姓名:");
fflush(stdin);
gets(x[i].name);
printf ("输入学生C语言成绩:");
scanf ("%d",&x[i].c);
printf ("输入学生Java成绩:");
scanf ("%d",&x[i].Java);
ave(x[i].c,x[i].Java);
printf ("\n");
}
printf ("学号\t姓名\tC语言成绩\tJava成绩\t平均分\n");
for (i=0;i<N;i++)
{
printf ("%d\t %s\t %d\t\t %d\t\t %d\t\t\n",x[i].no,x[i].name,x[i].c,x[i].Java,ave(x[i].c,x[i].Java));
}
}
float ave(int c,int Java)
{
return (c+Java)/2;
}