| ||||||||||
| 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 | |||||||||
1519的问题?感觉不应该出现这个错误,有GCC,VC都编译,单步调试过?程序不长,参考了别人的写法,自己写的没考虑到大整数,只能到long.
错误代码:Runtime Error
这是程序:
#include<stdio.h>
#include<string.h>
#define MAX 100
int main(void)
{
int num=0,i,len;
char char_array[MAX];
for (;;)
{
num=0;
scanf("%s",char_array);
if (char_array[0] == 48)
break;
len=strlen(char_array);
for (i=0; i<len; i++)
num += (char_array[i]-48);
if ((num%9) != 0)
printf("%d\n",num%9);
else
printf("9\n");
}
return 0;
}
scanf("%s",char_array);这一句在第二次输入数据时,也不会有错误呀!别的地方实在看不出来了。
谢谢!
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator