| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 5870 人关注过本帖, 1 人收藏
标题:改了很久了,还是有错误,求大神帮忙,谢谢
只看楼主 加入收藏
大白涂
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2016-5-28
收藏(1)
 问题点数:0 回复次数:8 
改了很久了,还是有错误,求大神帮忙,谢谢
C:\Users\Administrator\Desktop\东.cpp(97) : error C2227: left of '->name' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(97) : error C2227: left of '->num' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(97) : error C2227: left of '->all' must point to class/struct/union
 printf("    名次    姓名    学号    总成绩    \n");
   for(i=0;i<sum;i++)
       printf("    %d      %s     %s       %d    \n",i+1,p->name,p->num,p->all);



C:\Users\Administrator\Desktop\东.cpp(114) : error C2440: '=' : cannot convert from 'struct stu (*)[200]' to 'struct STU *[200]'
p=&stu;

原编码是
#include "stdio.h"
#include "windows.h"
int sum=0,x,data=0;
struct stu
{
  char name[20];
  char num[20];
  int chinese_great;
  int math_great;
  int all;
}stu[200];/*定义学生结构体以及学生结构体数组*/
struct STU *temp;
struct STU *p[200];
void in();/*自定义学生信息输入函数*/
void all_swap();/*总分排名*/
void menu();/*菜单*/
void name_swap();/*姓名查找*/
void tongji();/*统计*/
int ssame(char a[],char b[]);/*字符串比对函数*/
void over();/*退出*/

void main()
{
menu();
    switch (x)
     {
      case 1 : data=1;system("cls");in();break;
      case 2 : system("cls");all_swap();break;
      case 3 : system("cls");name_swap();break;
   case 4 : system("cls");tongji();break;
     }

}
/*菜单*/
void menu()
{
    system("cls");
    printf("******************************学生成绩管理系统****************************\n");
    printf("请选择你需要的操作:\n");
    printf("1.录入学生成绩(姓名、学号、语文、数学成绩,总分自动计算)\n");
    printf("2.按总分排名次\n");
    printf("3.按姓名查找某学生成绩\n");
    printf("4.统计各课程的平均分、及格率、最高分、最低分\n");
    printf("5.打印成绩表\n");
    scanf("%d",&x);
  
}
/*学生信息输入函数*/
void in()
{
    int i;
    int end=1;
    for(i=0;i<200;i++)
    {
    sum++;
printf("请输入第%d个学生的信息:",i+1);
    printf("请输入第%d个学生的姓名: ",i+1);
        scanf("%s",&stu[i+1].name);
    printf("请输入第%d个学生的学号: ",i+1);
        scanf("%s",&stu[i+1].num);
    printf("请输入第%d个学生的语文成绩: ",i+1);
        scanf("%d",&stu[i+1].chinese_great);
    printf("请输入第%d个学生的数学成绩: ",i+1);
        scanf("%d",&stu[i+1].math_great);
    stu[i+1] .all=stu[i+1].chinese_great+stu[i+1].math_great;
    printf("\n\n\n\n\n         \n           1:继续录入\n           2:结束录入\n           请选择:");
      scanf("%d",&end);
     if(end==2)
     break;
  else if (end==1) system("cls");
     else  over();
    }/*FOR结束*/
system("cls");
main();
}/*学生信息输入函数结束*/
/*按总分排名*/
void all_swap()
{
int i,j,q=0;
for(i=0;i<=sum;i++)
p=&stu;

   for(i=0;i<=sum-1;i++)
       for (j=i+1;j<=sum;j++)
       {
       if(stu[j+1].all<stu[j].all)
          {
            temp=p;
            p=p[j];
            p[j]=temp;

           }
  
       }
       printf("    名次    姓名    学号    总成绩    \n");
   for(i=0;i<sum;i++)
       printf("    %d      %s     %s       %d    \n",i+1,p->name,p->num,p->all);
   printf("输入 1 返回主菜单,输入其他退出");
   scanf("%d",&q);
   if(q==1)
   {
    system("cls");
      main();
   }
   else  over();

}/*总分查询结束*/
/*名字查询*/
void name_swap()
{
int i,q;
char temp[20];
for(i=0;i<=sum;i++)
p=&stu;

printf("\n                 请输入您要查询的学生姓名\n");
scanf("%s",&temp);
    for (i=0;i<=sum;i++)
    {
           if(ssame(temp,p->name)==0)
     {
             system("cls");
             printf("你所查找的学生已找到\n 姓名:%s  \n 学号: %s  \n 数学成绩:%d  \n  语文成绩:%d  \n  总成绩:%d  ",p->name,p->num,p->chinese_great,p->math_great,p->all);
         printf("\n\n\n\n\n\n      输入 1 返回主菜单,输入其他退出");
               scanf("%d",&q);
               if(q==1)
      {
              system("cls");
                 main();
      }
                 else  over();
     }
      
     {
         system("cls");
         printf("\n\n\n\n\n\n      未找到与%s有关的记录",temp);
         printf("\n\n\n\n\n\n      输入 1 返回主菜单,输入其他退出");
                        scanf("%d",&q);
                        if(q==1)
      {
                        system("cls");
                           main();
      }
                           else  over();
     }
      
}

} /*名字查询结束*/
/*统计*/
void tongji()
{
int i,q,chinese_v,math_v,chinese_max=0,chinese_min=9999,math_max=0,math_min=9999;long sum_chinese=0,sum_math=0;
float chinese_p,math_p,p_c=0,p_m=0;
if(data==1)
{

          for(i=0;i<=sum;i++)
    {
               p=&stu;
      sum_chinese=p->chinese_great+sum_chinese;
               sum_math=p->math_great+sum_math;
               if(p->chinese_great>=60)
       p_c++;
      if(p->math_great>=60)
       p_m++;

}
     chinese_v=sum_chinese/sum;/*语文平均分*/
  math_v=sum_math/sum;/*数学平均分*/
  chinese_p=(p_c/sum)*100;/*语文及格率*/
  math_p=(p_m/sum)*100;/*数学及格率*/
        for(i=0;i<sum;i++)
  {
    chinese_max=max(chinese_max,p->chinese_great);
    chinese_min=min(chinese_min,p->chinese_great);
    math_max=max(math_max,p->math_great);
    math_min=min(math_min,p->math_great);
  }  
  printf("    科目        平均分            及格率       最高分    最低分\n");
        printf("    语文      %f     百分之%f     %d        %d  \n",chinese_v,chinese_p,chinese_max,chinese_min);
  printf("    数学      %f     百分之%f     %d        %d  \n",math_v,math_p,math_max,math_min);
   printf("\n\n\n\n\n\n      输入 1 返回主菜单,输入其他退出");
   scanf("%d",&q);
   if(q==1)
   {
    system("cls");
      main();
   }
   else  over();
  
}
else main();
}
/*字符串比对*/
int ssame(char a[],char b[])
{
  int p=0,flag=0;
  while (a[p]!='\0'||b[p]!='\0')
        {
          if((a[p]>b[p]) || (a[p]<b[p]))
             {
                flag=1;break;
             }

         p++;
        }
        if(flag==0)
        {
        if((a[p]!='\0') || (b[p]!='\0'))
          flag=1;
        }
        return flag;
}/*字符串比对结束*/
/*退出*/
void over()
{
int q;
  system("cls");
printf("\n\n\n\n\n\n\n\n\n     此操作将导致你退出本程序。\n1:确认退出  \n2:返回主菜单");
    scanf("%d",&q);
if(q==1)
  exit(1);
else if (q==2)
  main();
else over();
}


错误是
--------------------Configuration: 东 - Win32 Debug--------------------
Compiling...
东.cpp
C:\Users\Administrator\Desktop\东.cpp(81) : error C2440: '=' : cannot convert from 'struct stu (*)[200]' to 'struct STU *[200]'
        There are no conversions to array types, although there are conversions to references or pointers to arrays
C:\Users\Administrator\Desktop\东.cpp(88) : error C2440: '=' : cannot convert from 'struct STU *[200]' to 'struct STU *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Users\Administrator\Desktop\东.cpp(89) : error C2440: '=' : cannot convert from 'struct STU *' to 'struct STU *[200]'
        There are no conversions to array types, although there are conversions to references or pointers to arrays
C:\Users\Administrator\Desktop\东.cpp(97) : error C2227: left of '->name' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(97) : error C2227: left of '->num' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(97) : error C2227: left of '->all' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(114) : error C2440: '=' : cannot convert from 'struct stu (*)[200]' to 'struct STU *[200]'
        There are no conversions to array types, although there are conversions to references or pointers to arrays
C:\Users\Administrator\Desktop\东.cpp(120) : error C2227: left of '->name' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(123) : error C2227: left of '->name' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(123) : error C2227: left of '->num' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(123) : error C2227: left of '->chinese_great' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(123) : error C2227: left of '->math_great' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(123) : error C2227: left of '->all' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(160) : error C2440: '=' : cannot convert from 'struct stu (*)[200]' to 'struct STU *[200]'
        There are no conversions to array types, although there are conversions to references or pointers to arrays
C:\Users\Administrator\Desktop\东.cpp(161) : error C2227: left of '->chinese_great' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(162) : error C2227: left of '->math_great' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(163) : error C2227: left of '->chinese_great' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(165) : error C2227: left of '->math_great' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(175) : error C2227: left of '->chinese_great' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(175) : error C2227: left of '->chinese_great' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(176) : error C2227: left of '->chinese_great' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(176) : error C2227: left of '->chinese_great' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(177) : error C2227: left of '->math_great' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(177) : error C2227: left of '->math_great' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(178) : error C2227: left of '->math_great' must point to class/struct/union
C:\Users\Administrator\Desktop\东.cpp(178) : error C2227: left of '->math_great' must point to class/struct/union
Error executing cl.exe.

东.exe - 26 error(s), 0 warning(s)
搜索更多相关主题的帖子: Desktop 总成绩 Users 姓名 
2016-05-29 11:44
yangfrancis
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:贵宾
威 望:141
帖 子:1510
专家分:7661
注 册:2014-5-19
收藏
得分:0 
stu是结构体类型名称还是对象名称 回答这个问题先
2016-05-29 18:36
大白涂
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2016-5-28
收藏
得分:0 
是结构体类型
2016-05-31 21:14
yangfrancis
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:贵宾
威 望:141
帖 子:1510
专家分:7661
注 册:2014-5-19
收藏
得分:0 
那么定义的后面不应该有那个stu[200]
2016-06-01 12:34
大白涂
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2016-5-28
收藏
得分:0 
那要 怎么该啊
2016-06-01 22:43
yangfrancis
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:贵宾
威 望:141
帖 子:1510
专家分:7661
注 册:2014-5-19
收藏
得分:0 
struct stu      //定义结构体
{
 ...
};
stu s1;         //定义实例对象
stu s2;         //定义实例对象

这样来
2016-06-03 18:34
农民工
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:21
帖 子:109
专家分:639
注 册:2015-8-22
收藏
得分:0 
你把语句前面的行号复制出来 就能静态帮你看了
2016-06-25 15:31
EndlessPower
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-8-28
收藏
得分:0 
你这是用c语言编写的
2016-08-28 02:49
cybermaster
Rank: 2
等 级:论坛游民
帖 子:9
专家分:31
注 册:2016-9-11
收藏
得分:0 
问问题都没有分的呢,题主
2016-09-24 20:06
快速回复:改了很久了,还是有错误,求大神帮忙,谢谢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027828 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved