| ||||||||||
| 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 | |||||||||
问下,C++能过,但是GCC就WA,不知道两者对代码要求有什么不同!!?#include "stdio.h"
#include "string.h"
#include "math.h"
char a[10];
int main()
{
int i,j;
long sum,sum1;
while(1)
{
scanf("%s",a);
if(a[0]=='0') break;
sum=sum1=0;
j=strlen(a);
for(i=0;i<j;i++)
{
if(a[i]-'0'>4)
sum+=(a[i]-'1')*pow(9,j-i-1);
else
sum+=(a[i]-'0')*pow(9,j-i-1);
sum1+=(a[i]-'0')*pow(10,j-i-1);
}
printf("%ld: %ld\n",sum1,sum);
}
return 1;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator