9 The number of statistical programming appears all integers from 1 to 100

Write a program to count all integers from 1 to 100 occurrences 9
c language:
the X-single-digit integer represents 10% of
x / 10% 10 represents an integer of tens
x / 100 represents one hundred and so on ...

#include <stdio.h>
#include <stdlib.h>
int main() {
	int i=0, m=0;
	for (i = 1; i <= 100; i++) {
		if (i%10==9) {
			m++;
		}
		if (i/10 == 9) {
			m++;
		}
	}
	printf("出现9的次数为:%d\n", m);
	system("pause");
	return 0;
}

Guess you like

Origin blog.csdn.net/Amoralmmm/article/details/93136311