C++ 各位大神们,请帮我看看这个程序吧,为什么运行老是出错?unresolved external symbol
#include<iostream>usingnamespacestd;intmain(){voidsort1(inta[],intn);intseek1(inta[],...
#include<iostream>
using namespace std;
int main()
{
void sort1(int a[],int n);
int seek1(int a[],int n);
int add1(int a[],int n);
int m,b,i,n,a[100];
cout<<"请输入你所输入数组的个数:";
cin>>n;
cout<<"请输入一组数组";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"请输入1-3中的数字,实现你所想要操作的方向,1为排序,2为查找,3为求和:";
cin>>m;
switch(m)
{
case 1:sort1(a,n);for(i=0;i<n;i++)cout<<a[i];break;
case 2:b=seek1(a,n);if(b==-1)cout<<"你所找的数字不在数组中";if(b!=-1)cout<<"该数字在数组中是第"<<b<<"个";break;
case 3:add1(a,n);cout<<"和为:"<<add1(a,n);break;
}
return 0;}
void sort1(int a[],int n)
{
int i,j,t;
for(i=1;i<=n-1;i++)
for(j=0;j<n-i;j++)
if(a[i]>a[i+1])
{t=a[i];a[i]=a[i+1];a[i+1]=t;}
}
int seek1(int a[],int n)
{
int m;
cout<<"请输入你要查找的数字";
cin>>m;
int q;
for(q=0;q<n;q++)
{ if(a[q]==m)
return q+1;}
return -1;
}
int add(int a[],int n)
{
int w,sum=0;
for(w=0;w<n;w++)
sum=sum+a[w];
return sum;
}
说error LNK2001: unresolved external symbol "int __cdecl add1(int * const,int)" (?add1@@YAHQAHH@Z) Debug/d.exe : fatal error LNK1120: 1 unresolved externals 展开
using namespace std;
int main()
{
void sort1(int a[],int n);
int seek1(int a[],int n);
int add1(int a[],int n);
int m,b,i,n,a[100];
cout<<"请输入你所输入数组的个数:";
cin>>n;
cout<<"请输入一组数组";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"请输入1-3中的数字,实现你所想要操作的方向,1为排序,2为查找,3为求和:";
cin>>m;
switch(m)
{
case 1:sort1(a,n);for(i=0;i<n;i++)cout<<a[i];break;
case 2:b=seek1(a,n);if(b==-1)cout<<"你所找的数字不在数组中";if(b!=-1)cout<<"该数字在数组中是第"<<b<<"个";break;
case 3:add1(a,n);cout<<"和为:"<<add1(a,n);break;
}
return 0;}
void sort1(int a[],int n)
{
int i,j,t;
for(i=1;i<=n-1;i++)
for(j=0;j<n-i;j++)
if(a[i]>a[i+1])
{t=a[i];a[i]=a[i+1];a[i+1]=t;}
}
int seek1(int a[],int n)
{
int m;
cout<<"请输入你要查找的数字";
cin>>m;
int q;
for(q=0;q<n;q++)
{ if(a[q]==m)
return q+1;}
return -1;
}
int add(int a[],int n)
{
int w,sum=0;
for(w=0;w<n;w++)
sum=sum+a[w];
return sum;
}
说error LNK2001: unresolved external symbol "int __cdecl add1(int * const,int)" (?add1@@YAHQAHH@Z) Debug/d.exe : fatal error LNK1120: 1 unresolved externals 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询