阅读背景:

7月14日作业

来源:互联网 

1.题目:通过编程实现,统计1~n有多少个9 

#include <stdio.h> void Count(int n) { int i; int temp; int count = 0; int b; for(i = 1; i <= n; i++) { temp = i; while(temp != 0) { b = temp % 10; temp = temp / 10; if(b == 9) { count++; } } } printf("The result is:%d\n", count); } int main() { int n; printf("Enter a number!\n"); scanf("%d", &n); Count(n); return 0; } #include <stdio.h> void Co



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: