怎么把几个源文件连接起来???
吃是哲学 2013-01-30 09:25:18 写了个小东西,想把几个源文件连接起来
1.cpp
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
cout<<"请输入题目个数:";
int num;
cin>>num;
cout<<endl;
cout<<"请选择题目难度:"<<endl;
int a,b,c;
cout<<"一·关于加减乘除:1.只有加减 2.只有乘除 3.两者都有 __\b\b";
cin>>a;
cout<<endl;
cout<<"二·关于数字类型:1.有负数 2.有小数 3.两者都有 4.两者都无 __\b\b";
cin>>b;
cout<<endl;
cout<<"三·关于数字范围:1.正负10以内 2.正负100以内 3.无限制 __\b\b";
cin>>c;
cout<<endl;
int max;
}
————————————————————————————————————————————————
2.cpp
if(c==1)
max=10;
else if(c==2)
max=100;
else if(c==3)
max=10000;
int i=1,j,answer,score=0,x,y;
if(b==4)
{
if(a==1)
{
while(i<=num/2)
{
x=rand();
y=rand();
if(x+y<max&&x>=0&&y>=0)
{
cout<<x<<"+"<<y<<"=";
cin>>answer;
if(answer==x+y)
{
cout<<"正确"<<endl;
score++;
}
else
{
cout<<"错误"<<","<<"答案应为:"<<x+y<<endl;
}
i++;
}
}
j=num-i;
i=0;
while(i<=j)
{
x=rand();
y=rand();
if(x>=y&&x>0&&y>0&&x<max&&y<max)
{
cout<<x<<"-"<<y<<"=";
cin>>answer;
if(answer==x-y)
{
cout<<"正确"<<endl;
score++;
}
else
{
cout<<"错误"<<","<<"答案应为:"<<x-y<<endl;
}
i++;
}
}
cout<<"满分为"<<num<<"分,"<<"您的成绩为:"<<score<<"分"<<endl;
}
________________________________________________________________________________________________
3.cpp
else if(a==2)
{
i=1;
score=0;
while(i<=num/2)
{
x=rand();
y=rand();
if(x*y<max&&x>0&&y>0)
{
cout<<x<<"×"<<y<<"=";
cin>>answer;
if(answer==x*y)
{
cout<<"正确"<<endl;
score++;
}
else
{
cout<<"错误"<<","<<"答案应为:"<<x*y<<endl;
}
i++;
}
}
j=num-i;
i=0;
while(i<=j)
{
x=rand();
y=rand();
if(x>=y&&x>=0&&y>0&&x%y==0&&x<max&&y<max)
{
cout<<x<<"÷"<<y<<"=";
cin>>answer;
if(answer==x/y)
{
cout<<"正确"<<endl;
score++;
}
else
{
cout<<"错误"<<","<<"答案应为:"<<x/y<<endl;
}
i++;
}
}
cout<<"满分为"<<num<<"分,"<<"您的成绩为:"<<score<<"分"<<endl;
}
}
}
类似的几个这种,怎么做啊?新手菜比求助..