C语言函数间传输二维数组的问题。

#include<stdio.h>intscore[30][2],p,sum=0;voidAppend();voidToave(intscore[]);voidSortS... # include <stdio.h>
int score[30][2],p,sum=0;
void Append();
void Toave(int score[]);
void SortScore(int number[],int score[]);
void SortNumber(int number[],int score[]);
void Sear(int number[],int score[]);
void Analysis(int number[],int score[]);
void List(int number[],int score[]);
int main()
{
int a;
while(1){
printf("1. Append record\n");
printf("2. Caculate total and average score of course\n");
printf("3. Sort in descending order by score\n");
printf("4. Sort in ascending order by number\n");
printf("5. Search by number\n");
printf("6. Statistic analysis\n");
printf("7. List record\n");
printf("0. Exit\n");
printf("Please enter your choice:");
scanf("%d",&a);
if(a==1)
{
Append();
}
if(a==2)
{
Toave(score);
}
if(a==3)
{
SortScore(score);
}
if(a==4)
{
SortNumber(score);
}
if(a==5)
{
Sear(score);
}
if(a==6)
{
Analysis(score);
}
if(a==7)
{
List(score);
}
if(a==0)
{
break;
}
}
return 0;
}
void Append()
{
int i;
printf("Please input the number of the students:");
scanf("%d",&p);
printf("Please input the ID and score of the students:\n");
for(i=0;i<p;i++)
{
scanf("%d %d",&score[i][i/2+1];
}
}
void Toave(int score[30][2])
{
int i;
for(i=0;i<p;i++)
{
sum=sum+score[i][2];
}
printf("Total score is %d.\n",sum);
printf("Average score is %d.\n",sum/p);
}
后面一部分不往上贴了- -好像是在函数间传输二维数组的时候格式有问题啊= =求大神
展开
 我来答
笑年1977
推荐于2016-07-10 · TA获得超过7.2万个赞
知道大有可为答主
回答量:2.2万
采纳率:81%
帮助的人:1.2亿
展开全部
# include <stdio.h>
int score[30][2],p,sum=0;
void Append();
void Toave(int score[]);
void SortScore(int number[],int score[]);
void SortNumber(int number[],int score[]);
void Sear(int number[],int score[]);
void Analysis(int number[],int score[]);
void List(int number[],int score[]);
int main()
{
int a;
while(1){
printf("1. Append record\n");
printf("2. Caculate total and average score of course\n");
printf("3. Sort in descending order by score\n");
printf("4. Sort in ascending order by number\n");
printf("5. Search by number\n");
printf("6. Statistic analysis\n");
printf("7. List record\n");
printf("0. Exit\n");
printf("Please enter your choice:");
scanf("%d",&a);
if(a==1)
{
Append();
}
if(a==2)
{
Toave(score);
}
if(a==3)
{
SortScore(score);
}
if(a==4)
{
SortNumber(score);
}
if(a==5)
{
Sear(score);
}
if(a==6)
{
Analysis(score);
}
if(a==7)
{
List(score);
}
if(a==0)
{
break;
}
}
return 0;
}
void Append()
{
int i;
printf("Please input the number of the students:");
scanf("%d",&p);
printf("Please input the ID and score of the students:\n");
for(i=0;i<p;i++)
{
scanf("%d %d",&score[i][i/2+1]; //i/2+1是什么意思
}
}
void Toave() //这里不要参数,因为score[30][2]是全局变量。
{
int i;
for(i=0;i<p;i++)
{
sum=sum+score[i][2]; //这个错误,第二维数组是0,1,没有2哦
}
printf("Total score is %d.\n",sum);
printf("Average score is %d.\n",sum/p);
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式