程序报错找不到原因高手进来看看

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

int *JosephWithArray(int n)
{
        int *p;
        p = new int[n];
        int i;
        for(i=0;i<n;i++)
        {
                p[i]=i+1;
        }
        return p;
}
int NextPeople(int prev,int *WorkingArray,int number_of_people,int step)
{
        int count=0;
        int travel=prev;
        int emptyplace=0;
        while(count<step)
        {
                travel=(travel+1)%number_of_people;
                if(WorkingArray[travel])
                {
                        count++;
                        emptyplace=0;
                }
                else
                {
                        emptyplace++;
                        if(emptyplace==number_of_people)
                        {
                                return -1;
                        }
                }
        }
        return travel;
}
void CreatOutput(int *WorkingArray,int number_of_people,int step)
{
        int i;
        int outnum=-1;
        for(i=0;i<number_of_people;i++)
        {
                outnum=NextPeople(outnum,WorkingArray,number_of_people,step);
                assert(outnum>-1 && outnum<number_of_people);
                printf("%d",WorkingArray[outnum]);
                WorkingArray[outnum]=0;
        }
        printf("\n");
}
void Dispose(int *WorkingArray)
{
        delete[] WorkingArray;
}

int main()
{
        int n,m;
        int *WorkingArray;

        printf("input number of people:");
        scanf("%d",&n);
        printf("input step:");
        scanf("%d",&m);

        WorkingArray = JosephWithArray(n);
        CreatOutput(WorkingArray,n,m);
        Dispose(WorkingArray);

        return 0;
}
Compiling...
1234.c
F:\测试代码\1234.c(8) : error C2065: 'new' : undeclared identifier
F:\测试代码\1234.c(8) : warning C4047: '=' : 'int *' differs in levels of indirection from 'int '
F:\测试代码\1234.c(8) : error C2143: syntax error : missing ';' before 'type'
F:\测试代码\1234.c(9) : error C2143: syntax error : missing ';' before 'type'
F:\测试代码\1234.c(10) : error C2065: 'i' : undeclared identifier
F:\测试代码\1234.c(55) : error C2065: 'delete' : undeclared identifier
F:\测试代码\1234.c(55) : error C2059: syntax error : ']'
执行 cl.exe 时出错.


1234.obj - 1 error(s), 0 warning(s)
看看这是怎么回事尽量说详细点
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值