帮我看下下面的程序那里错了!我学的是C语言基础,运行平台式c++

来源:百度知道 编辑:UC知道 时间:2024/06/14 17:22:09
题目是:
there is a list as below
id_number name math computer
1 zhangsan 70 86
2 lisi 62 79
3 wangwu 66 99
// 9.cpp : 定义控制台应用程序的入口点。
#include "stdafx.h"
#include "conio.h"
struct stu_rec
{
int id;
char[10];
float math,computer;
};
struct stu_rec each_stu[3]={{1,"zhangsan",70,80},{2,"lisi",62,79},{3,"wangwu",66,99}};

int _tmain(int argc, _TCHAR* argv[])
{
int i,j;
float max=0;
for(i=0;i<=2;i++)
if(max<each_stu[i].computer)
{
j=i;
max=each_stu[i].computer;
}
printf("name: %s\tcomputer: %g",each_stu[i].name,each_stu[j].computer);
printf("press any key to continue..");
getch();
}

printf("name: %s\tcomputer: %g",each_stu[i].name,each_stu[j].computer);
第一个[]里面应该是j

printf("name: %s\tcomputer: %g",each_stu[i].name,each_stu[j].computer);
你是要输出最大的吗?那应该是each_stu[j].name才对。你不会是在一个C++文件里写的这个程序吧?