65,210
社区成员
发帖
与我相关
我的任务
分享for(int j = 0;j < 20;++j)
l.p[j] = j+1;
for(int x = i+k;x <= l.length; ++x)
{
l.p[i] = l.p[i+k-1]; //这是赋值,不是删除,l的长度咋会减少啊
}
l.length = l.length-k;
#include<iostream>
using std::cout;
using std::endl;
#define OK 1
const int n0=100;
typedef int status;
typedef struct arrangelist
{
int p[n0+1];
int length;
} arrange;
status shanchu(arrange &l,int i,int k)
{
for(int j = 0;j < 20;++j) //??你为什么要在这里初始化呢?、
l.p[j] = j+1;
l.length = 20; // 结构体里的变量赋值
for(int x = i;x <= k; ++x) //你是不是想从第i各元素开始的k个元素删除??
{
l.p[i] = l.p[i+k-1];
}
l.length = l.length-k;
for( j = 0;j < l.length;++j)
cout<<l.p[j]<<"--";
return OK;
}
void main() //lz你的main写错了
{
arrange* dui = new arrange;
shanchu(*dui,6,3);
}
#include <iostream>
#define OK 1
using namespace std;
const int n0=100;
typedef int DataType;
typedef int status;
typedef struct arrangelist
{
int p[n0+1];
int length;
}arrange;
status shanchu(arrange &l,int i,int k)
{
for(int j = 0;j < 20;++j)
l.p[j] = j+1;
l.length=20; //要加上这句
for(int x = i+k;x <= l.length; ++x)
{
// l.p[i] = l.p[i+k-1]; //你这句好像有问题吧
l.p[x-k] = l.p[x];
}
l.length = l.length-k;
for(int j = 0;j < l.length;++j)
cout <<l.p[j]<<" ";
return OK;
}
int main() //你的主函数 写错了,你写成了mian 当然找不到入口地址了
{
arrange dui;
shanchu(dui,6,3);
system("pause");
return 0;
}