weixin_44101400
weixin_44101400
2018-12-14 07:53

大佬们好,我是c语言的初学者,请问为什么这个程序语法没错运行时里面有个函数task6没有被执行

  • c语言

#include
#include
#define N 30
void Input(int n,int *p1, char *p3[N], char *p2[N]);
void Average(int n,int *p1);
void Task6(int n,int *p1, char *p3[N], char *p2[N]);
int main()
{
int n, sorce[N];
int *p1=sorce;
printf("how many students?\n");
scanf("%d",&n);
char number[n][N];
char name[n][N];
char *p2[N];
char *p3[N];
int i = 0;
for(;i<n;i++)
{
p2[i]=name[i];
p3[i]=number[i];
}
Input(n,p1,p3,p2);
Average(n,p1);
Task6(n,p1,p3,p2);
}

void Input(int n,int *p1, char *p3[N], char *p2[N])
{
int i=0;
for(;i<n;i++)
{
printf("No.%d students name: \n",i+1);
getchar();
gets(*p2+i);
printf("the students number: \n");
gets(*p3+i);
printf("thr students sorce: \n");
scanf("%d",(p1+i));

}

}

void Average(int n,int p1)
{
int i=0,sum=0;
for(;i<n;i++)
{
sum+=
(p1+i);
}
printf("the sum is %d\n",sum);
printf("the average is %d\n",sum/n);
}

void Task6(int n,int *p1, char *p3[N], char *p2[N])
{
int temp1;
char *temp2;
char *temp3;
int i =0,j;
for(;i {
for(j=i+1;j {
if(p1[i]>p1[j])
{
temp1 = p1[i];
p1[i] = p1[j];
p1[j] = temp1;
temp2 = p2[i];
p2[i] = p2[j];
p2[j] = temp2;
temp3 = p3[i];
p3[i] = p3[j];
p3[j] = temp3;

        }

    }
 }
 for(;i<n;i++)
 {
    printf("%6d%13s%13s\n",p1[i],p2[i],p3[i]);
 }

}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答