|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<stdio.h>
#define M 100
typedef struct abu
{
int num;
char name[M];
int age;
union
{
char degree;
int grade;
}score;
}emploree;
int main()
{
int n,h=0,i;
scanf("%d",&n);
emploree s[n];
for(i=0;i<n;i++)
{
scanf("%d%s%d",&s[i].num,s[i].name,&s[i].age);
if(s[i].age>30)
{
scanf("%c",s[i].score.degree);
if(s[i].score.degree<='C')
h++;
}
else
{
scanf("%d",s[i].score.grade);
if(s[i].score.grade>=60)
{
h++;
}
}
}
printf("%d",h);
return 0;
}
首先你 编译应该不不会通过的 , 你所谓的共用体初始化 不能用 变量初始化的为了安全。
其次 除了前两个 scanf 你使用了 取地址& 符号,其余一概没用取地址 程序肯定崩溃!
|
|