代码没有错误,但是无法调用函数。不知道ru'he'gai
#include <iostream>
#include <ctime>
#include <stdlib.h>
using namespace std;
void randarray(int a[],int n)
{
srand(time(NULL));
for(n=0;n<=5;n++)
{
a[n]=rand()%100;
}
cout<<"插入数字前的数组:"<<endl;
for (n=0;n<5;n++)
cout<<a[n]<<endl;
}
int insert(int a[],int n)
{
int x,y,z,l;
cout<<"在第几位插入数字:"<<endl;
cin>>x;
y=x-1; //实际插入在y位
cout<<"插入的数字:"<<endl;
cin>>z;
for (n=2;n>=y;n--)
{
a[n+1]=a[n]; //n>y的全部往后移
}
a[y]=z; //第y位输出z
cout<<"新输出的数组:"<<endl;
{
for (l=0;l<8;l++)
cout<<a[l]<<endl;
}
return 0;
}
int del(int a[],int n)
{ int i,g,k,t;
cout<<"删除第几位:"<<endl;
cin>>g;
k=g-1;//实际删除的位置
for (i=g;i<=5;i++)
{
a[i-1]=a[i];//g后面的往前移
}
cout<<"删除后的数组:"<<endl;
{
for (t=0;t<4;t++)
cout<<a[t]<<endl;
}
return 0;
}
int main()
{
void randarray(int a[]);
int insert(int a[]);
int del(int a[]);
return 0;
}