求解以下几个编程错在哪里
(1)#include<iostream>
//在原升序数组中插入一个数,使其按原排序规律组成新数组
using namespace std;
void main()
{void fun(int ,int );
int a[5]={1,2,5,6,9},b,i;
//确定已知数组a[5],以及插入数b
cout<<"please input the number:";
cin>>b;
//确定输入的数是什么数,再来判断该放在哪里
cout<<"原数组是:"<<endl;
for(i=0;i<=4;i++)
{
cout<<a[i]<<" ";
}
//输出原数组
fun(a[5],b);
}
//主函数结束,声明函数---------------------------------------------
void fun(int a[5],int b)
{
int s[6],i,j=0;
for(i=0;i<=4;i++)
{if(b<a[i]) s[j]=b;
cout<<s[j++];
//依次判断a是否比a[i]小,若是则将a插在a[i]前面,将后面的元素后移。
if(b>=a[i]) s[j]=a[i];
cout<<s[j++];
}
}
//该程序错误:(1)error LNK2001: unresolved external symbol "void __cdecl fun(int,int)" (?fun@@YAXHH@Z)
//(2)fatal error LNK1120: 1 unresolved externals
(2)
#include<iostream>
//将原数组按倒序方式排序
using namespace std;
void fun(int );
int main()
{int a[100],i;
cout<<"please input the number:"<<endl;
for(i=0;i<=99;i++)
{cin>>a[i];
}
//键盘输入一连串数组
fun(a[100]);
}
void fun(int a[100])
{int s[100],i;
for(i=0;i<=99;i++)
{s[i]=a[100-i];
//倒序
cout<<s[i]<<endl;
//将倒序后的数组输出
}
}
//该程序错误:(1)error LNK2001: unresolved external symbol "void __cdecl fun(int,int)" (?fun@@YAXHH@Z)
//(2)fatal error LNK1120: 1 unresolved externals
(3)[这题一点都不会写]
#include<iostream>
//小白鼠由出口至入口的路径(由2表示)
using namespace;
void fun(int );
int main()
{int maze[7][7]={{1,1,1,1,1,1,1},
{1,0,0,0,0,0,1},
{1,0,1,0,1,0,1},
{1,0,0,1,0,1,1},
{1,1,0,1,0,1,1},
{1,0,0,0,0,0,1},
{1,1,1,1,1,1,1}};
int i,j;
for(i=0;i<=6;i++)
{for(j=0;j<=6;j++)
{cout<<maze[i][j];
}
cout<<endl;
}
fun(maze[7][7]);
}
void fun(int maze[7][7])
{int i=2,j=2;
if(maze[i][j+1]==0)
}
(2)#include<iostream>
//计算并输出给定整数n的所有因子(不包括1与自身)之和(规定n的值不大于1000)
using namespace std;
int fun(int a)
{int i,sum=0;
//sum各因子之和
for(i=2;i<a;i++)
{if(a%i==0) sum=sum+i;
}
return sum;
}
//----------------------------------------以下是主函数
int main()
{int n;
cout<<"please input the number(the number<=1000):"<<endl;
cin>>n;
fun(n);
cout<<"the result sum is:"<<fun(n)<<endl;
}
//系统指出的错误是:unexpected end of file while looking for precompiled header directive
(3)#include<iostream>
//用递归算法计算从n个人中选择k个人组成一个委员会的不同组合数
using namespace std;
int comm(int n,int k)
{int s;
if(k==1) s=n;
else s=comm(n-1,k)+comm(n-1,k-1);
return s;
}
//----------------------------------------------------以下为主函数
int main()
{int n,k,m;
cout<<"please input the number:"<<endl;
//输入从n个人中选择k个
cin>>n>>k;
m=comm(n,k);
cout<<"the result is:"<<m<<endl;
}
//零错误,可是运行不出结果