我已经编写了代码来解决问题.
这是我的代码:
t=int(input())
print("")
while(t):
s=0
n=int(input())
for i in range(n):
no=int(input())
s=s+no
if s%n==0:
print("YES")
else:
print("NO")
print("")
t-=1
Run Code Online (Sandbox Code Playgroud)
当我在OS X终端上运行它时,它工作正常.但是当我运行它IDEone或将其作为解决方案提交时,它会给出错误line 5:
ValueError:基数为10的int()的无效文字:''
我不确定问题是什么.
我的代码是
#include <stdio.h>
int main()
{
int n;
unsigned long int a,x;
scanf("%d",&n);
while(n--)
{
scanf("%lu",&a);
int count=0;
while(a!=0)
{
x=a%10;
printf("x=%lu\n",x );
if(x!=4||x!=7)
{
count++;
}
printf("count =%d\n",count );
a=a/10;
}
//printf("%d\n",count );
}
}
Run Code Online (Sandbox Code Playgroud)
我观察到当x = 4或x = 7计数增加时,它不应该因为我在其中放入了if条件.