![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
请C语言大神帮忙修改下,错在哪
#include<stdio.h>#include<cstdlib>#include<iostream>typestructstudents{intnum[]={1001...
#include <stdio.h>
#include <cstdlib>
#include <iostream>
type struct students
{
int num[]={1001,1002,1003,1004,1005};
char *name[]={
"丁一","马二","张三","李四","王五"
};
int math[]={90,80,95,70,91
};
int computer[]={
95,85,91,84,84
};
int english[]={
85,90,99,86,92
};
int level[]={
90,85,95,80,89
}st;
};
int main(int argc, char *argv[])
{
int i;
for (i=0;i<5;i++)
{
if (st.level[i]>=90)
{
printf("d",st.name[i]);
}
}
return 0;
} 展开
#include <cstdlib>
#include <iostream>
type struct students
{
int num[]={1001,1002,1003,1004,1005};
char *name[]={
"丁一","马二","张三","李四","王五"
};
int math[]={90,80,95,70,91
};
int computer[]={
95,85,91,84,84
};
int english[]={
85,90,99,86,92
};
int level[]={
90,85,95,80,89
}st;
};
int main(int argc, char *argv[])
{
int i;
for (i=0;i<5;i++)
{
if (st.level[i]>=90)
{
printf("d",st.name[i]);
}
}
return 0;
} 展开
展开全部
程序改正如下:
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#define MAX 100 //宏定义
//自定义结构体students
struct students
{
int num[MAX];
char name[MAX][MAX];
int math[MAX];
int computer[MAX];
int english[MAX];
int level[MAX];
};
//定义结构体students类型的变量stu
struct students stu={
{1001,1002,1003,1004,1005},
{
"丁一","马二","张三","李四","王五",
},
{90,80,95,70,91
},
{
95,85,91,84,84
},
{
85,90,99,86,92
},
{
90,85,95,80,89
}
};
int main(int argc, char *argv[])
{
int i;
for (i=0;i<5;i++)
{
if (stu.level[i]>=90)
{
printf("%s ",stu.name[i]);
}
}
return 0;
}
程序经过改正后,已通过编译测试。
回答完毕,如果感觉回答的好,请采纳哦!
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#define MAX 100 //宏定义
//自定义结构体students
struct students
{
int num[MAX];
char name[MAX][MAX];
int math[MAX];
int computer[MAX];
int english[MAX];
int level[MAX];
};
//定义结构体students类型的变量stu
struct students stu={
{1001,1002,1003,1004,1005},
{
"丁一","马二","张三","李四","王五",
},
{90,80,95,70,91
},
{
95,85,91,84,84
},
{
85,90,99,86,92
},
{
90,85,95,80,89
}
};
int main(int argc, char *argv[])
{
int i;
for (i=0;i<5;i++)
{
if (stu.level[i]>=90)
{
printf("%s ",stu.name[i]);
}
}
return 0;
}
程序经过改正后,已通过编译测试。
回答完毕,如果感觉回答的好,请采纳哦!
展开全部
先不说你打错的字
结构体里不能初始化变量,如果初始化,就相当于是类,要写在构造函数里,不能直接写。
然后typedef才对,然后st要写在struct最后的{}外,你写在里面了
然后printf里是%d
结构体里不能初始化变量,如果初始化,就相当于是类,要写在构造函数里,不能直接写。
然后typedef才对,然后st要写在struct最后的{}外,你写在里面了
然后printf里是%d
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-03-27
展开全部
aa.c:2:19: error: cstdlib: No such file or directory
aa.c:3:20: error: iostream: No such file or directory
aa.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘struct’
aa.c: In function ‘main’:
aa.c:27: error: ‘st’ undeclared (first use in this function)
aa.c:27: error: (Each undeclared identifier is reported only once
aa.c:27: error: for each function it appears in.)
用的什么编译器哦,这么多错误也看不出来??
aa.c:3:20: error: iostream: No such file or directory
aa.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘struct’
aa.c: In function ‘main’:
aa.c:27: error: ‘st’ undeclared (first use in this function)
aa.c:27: error: (Each undeclared identifier is reported only once
aa.c:27: error: for each function it appears in.)
用的什么编译器哦,这么多错误也看不出来??
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询