| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1952 人关注过本帖
标题:希望大家能够看看这个程序,它的报错很特别,我看不懂
取消只看楼主 加入收藏
renhu
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-11-27
收藏
 问题点数:0 回复次数:0 
希望大家能够看看这个程序,它的报错很特别,我看不懂

#include<iostream>
#include<math.h>
#include<vector>

using namespace std;

class findroot{
private:
double a,b,c,d,x1,x2;
public:
findroot(double x,double y,double z);
void find();
void display();
};

class seqlist{
private:
int num;
char name[10];
public:
int getnum(){return num;}
void dispname(){cout<<name;}
void setnum(int a){num=a;}
void setname(char b[]){strcpy(name,b);}
};

void findit();
void handle_menu(void);
int menu_select();

void game1();
void game2();

void joseph(seqlist [],int);
void joseph(vector<seqlist>&);


findroot::findroot(double x,double y,double z)
{
a=x;b=y;c=z;
d=b*b-4*a*c;
}

void findroot::find()
{
if(d>0)
{
x1=(-b+sqrt(d))/(2*a);
x2=(-b-sqrt(d))/(2*a);
return;
}
else if(d==0)
{
x1=x2=-b/(2*a);
return;
}
else
{
x1=-b/(2*a);
x2=sqrt(-d)/(2*a);
}
}

void findroot::display()
{
if(d>0)
{
cout<<"x1="<<x1<<"\nx2="<<x2<<endl;
return;
}
else if(d==0)
{
cout<<"x1=x2="<<x1<<endl;
return;
}
else
{
cout<<"x1="<<x1<<"+"<<x2<<"i"<<endl;
cout<<"x2="<<x1<<"-"<<x2<<"i"<<endl;
}
}

void fintit()
{
double a,b,c;
cout<<"这是个求方程ax2+bx+c=0的根的程序。"<<endl;
for(;;)
{
cout<<"输入方程系数a:";
cin>>a;
if(a==0)
{
getchar();
return;
}
cout<<"输入方程系数b:";
cin>>b;
cout<<"输入方程系数c:";
cin>>c;
findroot obj(a,b,c);
obj.find();
obj.display();
}
}

void joseph(seqlist c[],int length)
{
int m;
cout<<"please input first interval m(m<=20)";
cin>>m;
while(m>20)
{
cout<<"it is too large.please input another number:\n";
cin>>m;
}
cout<<"please input code:"<<endl;
getchar();

char s[10];
for(int i=0;i<length;i++)
{
cout<<"no"<<i+1<<"个人的名字:";
gets(s);
c[i].setname(s);
}
i=-1;
int j,k;
for(k=1;k<=length;k++)
{
j=0;
while(j<m)
{
i++;
if(i==length)
i=0;
if(c[i].getnum()!=0) j++;
}
if(k==length) break;
c[i].dispname();
cout<<",";

c[i].setname(0);
}
c[i].dispname();
cout<<endl;
}
void game1()
{
const int n=30;

int length=0;
cout<<"please input the munber of people:";
cin>>length;
seqlist c[n];
for(int i=0;i<length;i++)
{
c[i].setnum(i+1);
c[i].setname(" ");
}
joseph(c,length);
}

void game2()
{


int length=0;
cout<<"please input the munber of people:";
cin>>length;
vector<seqlist>c(length);
for(int i=0;i<length;i++)
{
c[i].setnum(i+1);
c[i].setname(" ");
}
joseph(c);
}

void joseph(vector<seqlist>&c)
{
int m;
cout<<"please input first interval m(m<=20)";
cin>>m;
while(m>20)
{
cout<<"it is too large.please input another number:\n";
cin>>m;
}
cout<<"please input code:"<<endl;
getchar();

char s[10];
for(int i=0;i<c.size();i++)
{
cout<<"no"<<i+1<<"个人的名字:";
gets(s);
c[i].setname(s);
}
i=-1;
int j,k;
vector<seqlist>::iterator p;
p=c.begin();
int length=c.size();
for(k=1;k<=length;k++)
{
j=0;
while(j<m)
{
i++;
if(i==c.size())
i=0;
j++;
}


if(k==length) break;
c[i].dispname();
cout<<",";

c.erase (p+i);
--i;
}
c[i].dispname();
cout<<endl;
}


void main()
{
handle_menu();
}

void handle_menu(void)
{
for(;;)
{
switch(menu_select())
{
case 1:
findit();
break;
case 2:
game1();
break;
case 3:
game2();
break;
case 4:
cout<<"\t再见!\n";
return;
}
}
}

int menu_select()
{
char s[2];
int cn;

cout<<"\t1.解一元二次方程\n";
cout<<"\t2.出圈游戏之一\n";
cout<<"\t3.出圈游戏之二\n";
cout<<"\t4.退出程序\n";
cout<<"\t选择1-4: ";

for(;;)
{
gets(s);
cn=atoi(s);
if(cn<1||cn>4)
printf("\n\t输入错误,重选1-4: ");
else
break;
}
return cn;
}


--------------------Configuration: practic2 - Win32 Debug--------------------
Linking...
main.obj : error LNK2001: unresolved external symbol "void __cdecl findit(void)" (?findit@@YAXXZ)
Debug/practic2.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

practic2.exe - 2 error(s), 0 warning(s)




搜索更多相关主题的帖子: double void include name 
2005-12-07 23:21
快速回复:希望大家能够看看这个程序,它的报错很特别,我看不懂
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021042 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved