作业帮 > 英语 > 作业

acm题为什么输出一直为0啊

来源:学生作业帮 编辑:作业帮 分类:英语作业 时间:2024/05/24 04:49:25
acm题为什么输出一直为0啊
CXB join an interview,the interviewer give him a problem.He is asked to reverse every number and calculate the summation of the new number.For instance,there are two numbers 10 and 14,the answer after reverse is 1 and 41,so the final answer is 1+41=42.
Input
The first line of the input contains n.(nx>>y;
while(x>0)
{
x=x/10;
n=n+1;
}
for(j=n;j>0;j--)
{
a=x%10;
b=b+a*(10^(j-1));
x=x/10;
}
while(y>0)
{
y=y/10;
m=m+1;
}
for(j=m;j>0;j--)
{
a=y%10;
c=c+a*(10^(j-1));
y=y/10;
}
d=c+b;
cout
#include
using namespace std;
int main()
{
int x,y,N,i,j,n=0,b=0,c=0,d,a,m=0;
cin>>N;
for(i=1;i>x>>y;
while(x>0)
{
x=x/10;
n=n+1;
}
for(j=n;j>0;j--)
{
a=x%10;
b=b+a*(10^(j-1));//^并不是表示次方
x=x/10;
}
while(y>0)
{
y=y/10;
m=m+1;
}
for(j=m;j>0;j--)
{
a=y%10;
c=c+a*(10^(j-1));
y=y/10;
}
d=c+b;
couty;
x=chang(x);
 y=chang(y);
 d=x+y;
cout
再问: 结果对了我也明白我的错了 但交上去是超时
再答: 是我的超时了吗? 可以改用scanf,printf这样会快一些
再问: 是 差了0.01秒 我不会改
再答: 题目地址可以地一下吗? #include #include using namespace std; int chang(int n) { int ret=0; while(n>0) { ret=ret*10+n%10; n/=10; } return ret; } int main() { int x,y,N,i,j,n=0,b=0,c=0,d,a,m=0; //cin>>N; scanf("%d",&N); for(i=1;i>x>>y; scanf("%d%d",&x,&y); x=chang(x); y=chang(y); d=x+y; //cout