求C语言高手解题!!

来源:百度知道 编辑:UC知道 时间:2024/05/05 19:11:37
我输入了学员信息,却不能正常输出学员成绩信息,为什么?
以下是我写的程序:
#include<stdio.h>
struct student
{
int no;
char name[20];
float fenshu[3];
float avr;
};
struct student stu[30];
struct student input();
void output(struct student stud[],int count);
void sort(struct student stud[],int count);
void add(struct student stud[],int count);
void del(struct student stud[],int count);
void main()
{

int count=0,choice;
while(1)
{
printf("=====1.录入学员成绩=====\n");
printf("=====2.显示学员成绩=====\n");
printf("=====3.查找学员成绩=====\n");
printf("=====4.添加学员成绩=====\n");
printf("=====5.删除学员成绩=====\n");
printf("=====6.退出 =====\n");
printf("\n");
printf("请输入你的选择:");
scanf("%d",&choice);
switch(choice)
{
case 1:input(

你好:
你的程序有这几个错误:
1.你的input函数没有给对应的student结构体,而是赋给一个局部变量,返回的局部变量也没有用到,所以student数组一直都是空的.
2.象LS说的那样,你的output函数参数count一直都是0,就算student数组中有值也不能够输出.
暂时就这么多...

int count=0
你调output的时候,把0作为count的值传进去了,这样当然不会输出啊,你要传的是那个数组的大小,不是0
如果你是在其它函数里面有修改count的值的话,那你函数的定义应该是
input(**,int &count)
要在count前加个引用,这样你在函数里面改了count值,main里面的count也会被改变
ps:我又当人肉编译器了?
发现标苦运先好认真哦,我都懒得仔细看,全局变量什么的也懒得理他,居然写了这么多,不凑热闹了嘿嘿

switch(choice)
{
case 1:input();
break程序到这就跳出去拉,选择语句没起作用,input没有可调用值

#include<stdio.h>
#include<stdlib.h> //system("")
struct student
{
int no;
char name[20];
float fenshu[3];
float avr;
};

// 改:尽量避免使用全局变量传递信息,使得程序更好理解
void input(struct student stu[], int* count);
void add(struct student stud[],int* count);
void del(struct student stud[],int* count);

void output(struct student stud[],int count);
void sort(stru