qq_33601547
qq_33601547
2016-01-02 15:33
采纳率: 50%
浏览 1.3k

C语言结构数组的题,请大神看看错误出在哪里

#include
struct sell
{
char dm[4];
char mc[10];
int dj;
int sl;
long int je;
}sell[100];
void main()
{
int i,j,t;
long int m;
for(i=0;i scanf("%s,%s,%4d,%5d,%5d\n",&sell[i]dm,&sell[i].mc,&sell[i].dj,&sell[i].sl,&sell[i].je);
for(i=0;i for(i=0;i if(struct(sell[i].mc>sell[i+1].mc)
{
t=sell[i].mc;
sell[i].mc=sell[i+1].mc;
sell[i+1].mc=t;
}
else if(sell[i].mc==sell[i+1].mc)
{
if(sell[i].je>sell[i+1].je)
{
m=sell[i].je;
sell[i].je=sell[i+1].je;
sell[i+1].je=m;
}
}

for(i=0;i<100;i++)
printf("%s,%s,%4d,%5d,%5d\n",sell[i].dm,sell[i].mc,sell[i].dj,sell[i].sl,sell[i].je);
}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • caozhy
    已采纳
     错误多着呢
    
    &sell[i]dm
    中间少了点
    
    struct(sell[i].mc>sell[i+1].mc
    这里多了struct(
    
    点赞 评论
  • sinat_23338865
    偏执灬 2016-01-03 01:47

    for(i = 0; i < 100; i++)
    {
    scanf("%s,%s,%4d,%5d,%5d\n",&sell[i]dm,&sell[i].mc,&sell[i].dj,&sell[i].sl,&sell[i].je)
    }
    for(i = 0; i < 100; i++)
    {
    if(sell[i].mc>sell[i+1].mc)
    ....

    }

    for循环的结构再好好看看资料吧

    点赞 评论

相关推荐