c++ function help!!

来源:百度知道 编辑:UC知道 时间:2024/05/17 00:15:12
Write a function that inputs two integers and outputs true if they are reverse of each other, and false otherwise. (For example, for inputs 543 and 345, it returns true; but for 567 and 769, it return false)

#include<iostream>
using namespace std;
bool fuction(int x,int y)
{ int a[8],b[8],times=10;
int j;
for(int i=0;x>0&&y>0;i++)
{
a[i]=x%10;
b[i]=y%10;
x/=10;
y/=10;
}
for(j=i-1,i=0;j>=0;j--,i++)
if(a[i]!=b[j])return false;
return true;
}

int main()
{
int x,y;
cout<<"Please the first two integers:";
cin>>x;
cout<<"Please the second two integers:";
cin>>y;
if(fuction(x,y)==true)cout<<"TRUE"<<endl;
else cout<<"FALSE"<<endl;
return 0;
}