技术小白奋斗中 2015-08-17 12:28 采纳率: 0%
浏览 1404

c语言指针问题,求大神,新手。

#include
#include
#include

struct Student
{
int age;
char name[100];
float score;
};

void Ininformation(int * IP_len, struct Student * IP_arr)
{
int i;

for (i = 0; i < *IP_len; ++i)
{
printf("请输入%d个学生信息: \n", *IP_len);
printf("请输入第%d个学生信息\n", i + 1);
printf("年龄 = ");
scanf_s("%d", &IP_arr[i].age);

printf("分数 = ");
scanf_s("%f", &IP_arr[i].score);

printf("姓名 = ");
scanf_s("%s", IP_arr[i].name);

}
}

void Sortinformation(int * SP_len, struct Student * SP_arr)
{
int i, j;
struct Student t;

for (i = 0; i < *SP_len; ++i)
{
for (j = 0; j {
if (SP_arr[j].score > SP_arr[j + 1].score)
{
t = SP_arr[j];
SP_arr[j] = SP_arr[j + 1];
SP_arr[j + 1] = t;
}
}
}
}

void Outinformation(int * OP_len, struct Student * OP_arr)
{
int i;

for (i = 0; i < *OP_len; ++i)
{
printf("第%d个学生的信息是:\n", i + 1);
printf("年龄 = %d\n", OP_arr[i].age);
printf("姓名 = %s\n", OP_arr[i].name);
printf("分数 = %f\n", OP_arr[i].score);
printf("\n\n");
}
}

int main(void)
{
int len;
struct Student * p_arr;

printf("请输入总共有几个学生:\n");
printf("人数 = ");
scanf_s("%d", &len);

p_arr = (struct Student *)malloc(len * sizeof(struct Student));

Ininformation(&len, p_arr);
Sortinformation(&len, p_arr);
Outinformation(&len, p_arr);

system("pause");
return 0;
}
存在错误,但是编译可以通过,求大神帮看下,谢谢。图片说明

  • 写回答

3条回答 默认 最新

  • 纵横车 2015-08-17 12:42
    关注

    for循环代码补全,求补上。

    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用