练习题
-
水仙花数
水仙花数是指三位数,这三位数满足:个位2 + 十位2 + 百位**2 = 这个三位数本身。#include<stdio.h> int main() { int num = 100; int the_uint, the_decade, the_hundred; for(num; num<1000; num++) { the_hundred = num/100; the_decade = (num - the_hundred * 100)/10; the_uint = num%10; if(the_uint*the_uint + the_decade*the_decade + the_hundred*the_hundred == num) { printf("水仙花数:%d\n", num); } } return 0; }
-
99乘法表
#include<stdio.h> int main() { int mul1, mul2; for(mul1=1; mul1<10; mul1++) { for(mul2=1; mul2<=mul1; mul2++) { printf("%d*%d=%d\t", mul1, mul2, mul1*mul2); } printf("\n"); } return 0; }