#include
#include
using namespace std;
int min(int n, int m);
int max(int n, int m);
const int N = 50;
void Read_Store(int Number[N], int &length);
void Add_Output();
int main()
{
cout<<" This is a calculate number program"<<endl;
}
int min(int n,int m)
{
return (n<m) ? n : m;
}
int max(int n,int m)
{
return (n>m) ? n : m;
}
void Read_Store(int Number[N],int &length)
{
string num ;
int i;
cout<<"please input a number:";
cin>>num;
length = num.length();
for (i = 0; i < length; i++)
{
Number[i] = num[length - 1 - i] - '0';
}
}
void Add_Output()
{
int i,carry;
int strlen_num1,strlen_num2;
int Num1[N],Num2[N],Result[N];
int minnum,maxnum;
Read_Store(Num1,strlen_num1);
Read_Store(Num2,strlen_num2);
minnum = min(strlen_num1,strlen_num2);
maxnum = max(strlen_num1,strlen_num2);
carry = 0;
for(i=0;i<minnum;i++)
{
Result[i] = (Num1[i] + Num2[i] + carry) % 10;
carry = (Num1[i] + Num2[i] + carry)/10;
}
if(strlen_num1>minnum)
{
for(i=minnum;i<strlen_num1;i++)
{
Result[i] = (Num1[i]+ carry) % 10;
carry = (Num1[i]+ carry)/10;
}
}
if(strlen_num2>minnum)
{
for(i=minnum;i<strlen_num2;i++)
{
Result[i] = (Num2[i]+ carry) % 10;
carry = (Num2[i]+ carry)/10;
}
}
if(carry>0)
{
Result[maxnum] = 1;
maxnum++;
}
cout<<"Result:";
for(i=maxnum-1;i>=0;i--)
{
cout<<Result[i];
}
cout<<endl;
system("pause");
return ;
}
int main 的函数 要求放在第一位,可是我就是运行不了。。为什么。。