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

不用开数组的方法

Posted by yzx at 2007-05-03 05:53:20 on Problem 2602
#include <stdio.h>

int main()
{
	int n,i;
	char a,b,c,d,k,l;

	scanf("%d", &n);

	k = 0;
	scanf("%d %d", &a, &b);
	l = (a + b) / 10;
	k = (a + b) % 10;
	if(l > 0)
	{
		printf("%d", l);
	}
	for(i = 1; i < n; i++)
	{
		c = l;
		d = k;
		scanf("%d %d", &a, &b);
		l = (a + b) / 10;
		k = (a + b) % 10;
		printf("%d", l + d);
	}
	printf("%d", k);
	printf("\n");
	return 0;
}
==================
实在找不到有什么问题了,大家帮忙看下是怎么回事,另外对题目有疑问,说输出的长度和输入的长度要一致,但如果出现下面的情况该怎么办?
2
9 9
9 9
按道理说应该得到198的,但这样就输出了3位,郁闷啊

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