在三道题中,只有这道题结果运行出来了,而且还是正确的,但是这道题在做的时候,没有正确的思路,想的不对,后来还是看了下网上的代码,才有的思路。所以这道题不算是我写出来的。我起初的想法时用字符类型的,然后用while语句,但是字符那块我真的很懵,搞不清楚。
#include <stdio.h>
#include <windows.h>
int main(){
int n;
int count = 0;
for (n = 1; n < 100; n++){
if (n % 10 == 9 ){
count++;
}
if (n / 10 == 9){
count++;
}
}
printf("count = %d\n", count);
system("pause");
return 0;
}