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 |
我的电脑上运行是对的,而提交后wrong answer.不知输入数组int a[100000]够不够大.若不够怎样设?#include "stdio.h" #include "malloc.h" int exchange(int a) { int result=0; while(a>10) { result=result+a%10; a=a/10; } result+=a; if(result>10) result=exchange(result); return result; } int main() { int a[100000]={0},i=0,k=0; while(1) { scanf("%d",&a[i]); if(a[i]==0)break; a[i]=exchange(a[i]); i++; } while(a[k]!=0) { printf("%d\n",a[k]); k++; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator