Count the number of occurrences of a number from 1 to 100

Count the number of occurrences of a number from 1 to 100

Take 5 as an example, the source code is as follows

#include<stdio.h>
int main()
{ int a, b = 0; for (a = 1; a <= 100; a++) { if (5=a% 10 ||5=a / 10) b++; } printf("The number of occurrences of 5 in 1-100 is:% d", b); return 0; }








Guess you like

Origin blog.csdn.net/qq_43745617/article/details/109428750