题解 | #数位五五#
数位五五
https://www.nowcoder.com/practice/4306996b0a534178b90b3514a8b30028
#include<stdio.h> int n5(int a,int b) { int k,x=0,c; for(int i=a;i<=b;i++) { k=0;//更新变量 c=i;//给新变量赋值,不能直接用i,不然会死循环 while(c) { k+=c%10; c/=10; } if(k%5==0) {x++;} } return x; } int main() { int a,b; scanf("%d%d",&a,&b); printf("%d",n5(a,b)); return 0; }