int readscore(int score[])
{
int i = 0;
do
{
scanf_s("%d", &score[i]);
i++;
} while (score[i] > 0);
return i;
}
表面上没什么问题
但如果运行一下,
假设score【0】=10
i=2;
但在 while 判断时 却成了 score【1】 score[1] 默认=0;
应该是用while判断score[0]
所以应对这段代码进行改正
int readscore(int score[])
{
int i = -1;
do
{
i++;
scanf_s("%d", &score[i]);
} while (score[i] > 0);
return i;
}