C语言代码实现:输出百位数与个位数之和为9的三位数
#include <stdio.h>
int main() {
int i;
for (i = 100; i <= 999; i++) {
int units = i % 10; // 取出个位数
int hundreds = i / 100; // 取出百位数
if (units + hundreds == 9) { // 判断个位数与百位数之和是否为9
printf('%d\n', i); // 输出符合条件的数
}
}
return 0;
}
原文地址: https://www.cveoy.top/t/topic/ld9Z 著作权归作者所有。请勿转载和采集!