| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2780 人关注过本帖
标题:出现error C2660: 'create' : function does not take 0 parameters怎么解决 ...
只看楼主 加入收藏
moliy
Rank: 2
等 级:论坛游民
帖 子:39
专家分:24
注 册:2012-4-25
结帖率:90%
收藏
已结贴  问题点数:4 回复次数:3 
出现error C2660: 'create' : function does not take 0 parameters怎么解决呢
#include <stdio.h>
#include <stdlib.h>
struct list
{
    int data;
    struct list* next;
};

struct list* create(int a[])
{
    struct list *head = NULL, *p, *q;
    int i;

    head = p = (struct list*)malloc(sizeof(struct list));
    p->data = 0;
    for (i = 1; i <= 10; i++)
    {
        q = (struct list*)malloc(sizeof(struct list));
        q->data =a[i] ;
        p->next = q;
        p = q;
    }
    p->next = NULL;
    return head;
}

void print(struct list* head)
{
    struct list* p = head;
    if (!head) puts("NULL");
    while (p)
    {
        printf("%d ", p->data);
        p = p->next;
    }
}

struct list* reverse(struct list* head)
{
    struct list *p = head, *q, *t;
    if (!head) return NULL;
    q = p->next;
    while (q)
    {
        t = q->next;
        q->next = p;
        p = q;
        q = t;
    }
    head->next = NULL;
    head = p;
    return head;
}

int main(void)
{
    struct list* head;
    head = create();
    head = reverse(head);
    print(head);
    return 0;
}
搜索更多相关主题的帖子: include function create next 
2012-10-06 10:53
爱闹的娃
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:3
帖 子:265
专家分:975
注 册:2011-10-23
收藏
得分:2 
creat()函数他要接受参数,应当creat(head)
2012-10-06 11:10
moliy
Rank: 2
等 级:论坛游民
帖 子:39
专家分:24
注 册:2012-4-25
收藏
得分:0 
回复 2楼 爱闹的娃
可是还是有问题
2012-10-06 15:09
pcbaichi
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
帖 子:486
专家分:1185
注 册:2010-11-13
收藏
得分:2 
#include <stdio.h>
#include <stdlib.h>
struct list
{
    int data;
    struct list* next;
};

struct list* create(int a[])
{
    struct list *head = NULL, *p, *q;
    int i;

    head = p = (struct list*)malloc(sizeof(struct list));
    p->data = 0;
    for (i = 1; i <= 10; i++)
    {
        q = (struct list*)malloc(sizeof(struct list));
        q->data =a[i] ;
        p->next = q;
        p = q;
    }
    p->next = NULL;
    return head;
}

void print(struct list* head)
 {
     struct list* p = head;
     if (!head) puts("NULL");
     while (p)
     {
         printf("%d ", p->data);
         p = p->next;
     }
 }

struct list* reverse(struct list* head)
 {
     struct list *p = head, *q, *t;
     if (!head) return NULL;
     q = p->next;
     while (q)
     {
         t = q->next;
         q->next = p;
         p = q;
         q = t;
     }
     head->next = NULL;
     head = p;
     return head;
 }

int main(void)
 {
     struct list* head;
     int a[2]={1,2};         //attention
     head = create(a);       //attention
     head = reverse(head);
     print(head);
     return 0;
 }


[ 本帖最后由 pcbaichi 于 2012-10-6 21:41 编辑 ]

免费赠送河蟹一只
2012-10-06 21:40
快速回复:出现error C2660: 'create' : function does not take 0 parameters怎 ...
数据加载中...
 
   



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

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