Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

1A留念,哈哈,贴个代码献丑,轻拍呀~

Posted by iwlam525 at 2011-08-27 09:28:53 on Problem 1504
#include <iostream>
using namespace std;

int trans(int a)
{
 	if(a % 10 == 0)
    {
 	    while(a % 10 == 0)
 	    {
		    a = a / 10;
		}
	}
	return a;
}

int reverse(int b)
{
 	int c = 0;
 	while(b)
 	{
		c = c * 10 + b % 10;
		b = b / 10;
	}
	return c;
}

int main()
{
 	int n, a, b, sum;
 	int i, j, k;
 	cin>>n;
 	while(n--)
 	{
  	    cin>>a>>b;
  	    a = trans(a);
  		b = trans(b);
  		a = reverse(a);
  		b = reverse(b);
  		sum = trans(a+b);
  		sum = reverse(sum);
  		cout<<sum<<endl;
  	}
 	//system("pause");
 	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator