h写入位置时发生访问冲突
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
void highest(int score[], int max, int* h[]);
int main()
{
int h[10][2] = {0}, l[10][2] = {0}, a[10][2] = {0};
int score[10] = { 0 };
for (int i = 0; i < 10; i++)
{
printf("请输入第%d个成绩", i + 1);
scanf_s("%d", &score[i]);
}
highest(score, 10, h);
printf("max\n");
for (int i = 0; i < 10; i++)
{
if (h[i][0] == 0 && i > 0)
continue;
else
printf("%d ", h[i][1]);
}
system("pause");
return;
}
void highest(int score[], int max, int* h[])
{
int k = 0,t = 0;
for (int i = 0; i < max; i++)
{
if (score[t] < score[i])
{
t = i;
}
}
for (int i = 0; i < max; i++)
{
if (score[i]==score[t])
{ //在这里出现报错
h[k][0] = i;/*二维数组第一位储存原始下标*/
h[k][1] = score[i];/*第二位储存成绩*/
k++;
}
}
}
写入位置时发生访问冲突
h的二维数组能在输入下表的同时,输入对应的成绩