静态类 level
获赞
0
粉丝
0
关注
0
看过 TA
0
长沙职业技术学院
2020
Java
IP属地:吉林
浪子我做,无岸可泊。
私信
关注
#include<stdio.h> int main()   {    int i,count,p,q;     scanf("%d%d",&p,&q);     count=0;     int a,c;     for(i=p+1;i<q;i++)     {       a=i;c=0;           while(a!=0){      c=c+a%10;//依次取出个位,十位,百位....               a=a/10;     }     if(c%5==0)count++;    }    printf(&qu...
弱到自闭的kench:您好!首先感谢您使用牛客网你的代码存在以下问题:本题的的要求是求pq的闭区间内有多少个数数位之和为5的倍数,而不是开区间内的数的个数。你仅需要修改一下for循环的范围即可。参考代码附上: #include<stdio.h> int main() { int i,count,p,q; scanf("%d%d",&p,&q); count=0; int a,c; for(i=p;i<=q;i++) { a=i;c=0; while(a!=0){ c=c+a%10; a=a/10; } if(c%5==0)count++; } printf("%d",count); return 0; }希望我的回答能使您满意!
0 点赞 评论 收藏
分享

创作者周榜

更多
关注他的用户也关注了:
牛客网
牛客网在线编程
牛客网题解
牛客企业服务