Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
不用开数组的方法#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator