| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 343 人关注过本帖
标题:各位高手,我这条代码报错提示如下,是什么问题啊?求指点,分不多,见谅! ...
只看楼主 加入收藏
tudou2xigua
Rank: 2
等 级:论坛游民
帖 子:87
专家分:54
注 册:2011-3-20
结帖率:90.32%
收藏
已结贴  问题点数:50 回复次数:5 
各位高手,我这条代码报错提示如下,是什么问题啊?求指点,分不多,见谅!先谢过!
#include<stdio.h>
#include<string.h>
#include<malloc.h>
#define FORMAT "%d,%s,%c,%d,%d,%d,%f,%f,%f,%f,%f"
#define  LEN sizeof(Student)
struct date
    {
        int year;
        int month;
        int day;
    };
typedef struct
{
    int Num;
    char Name[10];
    char Sex;
    struct date birthday[100];
    float English,DataStructure,CPlusPlus;
    float Sum,Average;
    struct date*next;
}Student;
Student stud[100];
struct date birthday[100];
int count=0;
Student*creat(void)          /*创建链表*/
{
    Student*head,*p1,*p2;
    p1=p2=(Student*)malloc(LEN);      /*开辟一个新单元*/
    scanf(FORMAT,&p1->Num,p1->Name,&p1->Sex,&p1->birthday->year,&p1->birthday->month,&p1->birthday->day,&p1->English,&p1->DataStructure,&p1->CPlusPlus,&p1->Sum,&p1->Average);
    head=NULL;
    while(p1->Num!=0)
    {
        count=count+1;
        if(count==1)
            head=p1;
        else
            p2->next=p1;
        p2=p1;
        p1=(Student*)malloc(LEN);
        scanf(FORMAT,&p1->Num,p1->Name,&p1->Sex,&p1->birthday->year,&p1->birthday->month,&p1->birthday->day,&p1->English,&p1->DataStructure,&p1->CPlusPlus,&p1->Sum,&p1->Average);
    }
    p2->next=NULL;
    return(head);
}
Student*Add(Student*head,Student*stu)        /*插入节点*/
{
    Student*p0,*p1,*p2;
    p1=head;
    p0=stu;
    if(head==NULL)
    {
        head=p0;
        p0->next=NULL;
    }
    else
    {
        while((p0->Num>p1->Num)&&(p1->next!=NULL))
        {
            p2=p1;
            p1=p1->next;
        }
        if(p0->Num<=p1->Num)
        {
            if(head==p1)
                head=p0;
            else
                p2->next=p0;
            p0->next=p1;
        }
        else
        {
            p1->next=p0;p0->next=NULL;
        }
    }
    count=count+1;
    return(head);
}
void main()
{
    Student stud1;
    printf("请输入要添加的学生信息:");
    scanf(FORMAT,&stud1.Num,stud1.Name,&stud1.Sex,&stud1.birthday->year,&stud1.birthday->month,&stud1.birthday->day,&stud1.English,&stud1.DataStructure,&stud1.CPlusPlus,&stud1.Sum,&stud1.Average);
    Add(stud,stud1);
}

D:\MSDev98\MyProjects\x3\x3.c(72) : warning C4133: '=' : incompatible types - from 'struct Student *' to 'struct date *'
D:\MSDev98\MyProjects\x3\x3.c(83) : error C2115: 'function' : incompatible types
D:\MSDev98\MyProjects\x3\x3.c(83) : warning C4024: 'Add' : different types for formal and actual parameter 2
搜索更多相关主题的帖子: English 
2011-06-01 10:25
laoyang103
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:内蒙古包头
等 级:贵宾
威 望:19
帖 子:3082
专家分:11056
注 册:2010-5-22
收藏
得分:50 
程序代码:
#include<stdio.h>
#include<string.h>
#include<malloc.h>
#define FORMAT "%d,%s,%c,%d,%d,%d,%f,%f,%f,%f,%f"
#define  LEN sizeof(Student)
struct date
    {
        int year;
        int month;
        int day;
    };
typedef struct Student
{
    int Num;
    char Name[10];
    char Sex;
    struct date birthday[100];
    float English,DataStructure,CPlusPlus;
    float Sum,Average;
    struct Student*next;
};
Student stud[100];
struct date birthday[100];
int count=0;
Student*creat(void)          /*创建链表*/
{
    Student*head,*p1,*p2;
    p1=p2=(Student*)malloc(LEN);      /*开辟一个新单元*/
    scanf(FORMAT,&p1->Num,p1->Name,&p1->Sex,&p1->birthday->year,&p1->birthday->month,&p1->birthday->day,&p1->English,&p1->DataStructure,&p1->CPlusPlus,&p1->Sum,&p1->Average);
    head=NULL;
    while(p1->Num!=0)
    {
        count=count+1;
        if(count==1)
            head=p1;
        else
            p2->next=p1;
        p2=p1;
        p1=(Student*)malloc(LEN);
        scanf(FORMAT,&p1->Num,p1->Name,&p1->Sex,&p1->birthday->year,&p1->birthday->month,&p1->birthday->day,&p1->English,&p1->DataStructure,&p1->CPlusPlus,&p1->Sum,&p1->Average);
    }
    p2->next=NULL;
    return(head);
}
Student*Add(Student*head,Student*stu)        /*插入节点*/
{
    Student*p0,*p1,*p2;
    p1=head;
    p0=stu;
    if(head==NULL)
    {
        head=p0;
        p0->next=NULL;
    }
    else
    {
        while((p0->Num>p1->Num)&&(p1->next!=NULL))
        {
            p2=p1;
            p1=p1->next;
        }
        if(p0->Num<=p1->Num)
        {
            if(head==p1)
                head=p0;
            else
                p2->next=p0;
            p0->next=p1;
        }
        else
        {
            p1->next=p0;p0->next=NULL;
        }
    }
    count=count+1;
    return(head);
}
void main()
{
    Student stud1;
    printf("请输入要添加的学生信息:");
    scanf(FORMAT,&stud1.Num,stud1.Name,&stud1.Sex,&stud1.birthday->year,&stud1.birthday->month,&stud1.birthday->day,&stud1.English,&stud1.DataStructure,&stud1.CPlusPlus,&stud1.Sum,&stud1.Average);
    Add(stud,&stud1);
}
没错了  但是逻辑错误还不知道  你自己来吧

                                         
===========深入<----------------->浅出============
2011-06-01 11:12
laoyang103
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:内蒙古包头
等 级:贵宾
威 望:19
帖 子:3082
专家分:11056
注 册:2010-5-22
收藏
得分:0 

                                         
===========深入<----------------->浅出============
2011-06-01 11:13
tudou2xigua
Rank: 2
等 级:论坛游民
帖 子:87
专家分:54
注 册:2011-3-20
收藏
得分:0 
回复 2楼 laoyang103
恩,行了,多谢了,楼上那附件是什么?
2011-06-01 12:03
w123012306
Rank: 9Rank: 9Rank: 9
来 自:湖南
等 级:蜘蛛侠
威 望:4
帖 子:307
专家分:1180
注 册:2010-4-22
收藏
得分:0 
顶2楼 ! 我才懂了

楼上,楼下的一定要幸福开心哦!
2011-06-01 12:25
laoyang103
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:内蒙古包头
等 级:贵宾
威 望:19
帖 子:3082
专家分:11056
注 册:2010-5-22
收藏
得分:0 
我写的链表模板  你可以套用  功能很全的

                                         
===========深入<----------------->浅出============
2011-06-01 20:23
快速回复:各位高手,我这条代码报错提示如下,是什么问题啊?求指点,分不多,见 ...
数据加载中...
 
   



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

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