摘要: #include int main(int argc, const char * argv[]) { int input = 0; std::cout>input; for(int i = 1;ii;--j) { std::cout<<" "; } for(... 阅读全文
posted @ 2016-07-17 11:28 看代码`lookdaima.com 阅读(3197) 评论(0) 推荐(0) 编辑
摘要: 编程求1000之内的所有“完数”。所谓“完数”是指一个数恰好等于他的因子之和。例如:6是完数,因为6=1+2+3。 提示:循环所有的数,用电脑计算加和结果。 答案: 6 28 496 解法(用while循环实现) 阅读全文
posted @ 2016-07-17 11:14 看代码`lookdaima.com 阅读(1160) 评论(0) 推荐(0) 编辑
摘要: 编程求“水仙花数”,所谓“水仙花数”是指一个三位数,其各位数字立方和等于该数本身。例如,153是水仙花数,因为153=1m³ + 5m³ + 3m³。 提示:要学会用循环语句,用电脑一个数字一个数字不停的运算,然后把100~999里面所有符合条件的数给打印出来。 答案是: 153 370 371 4 阅读全文
posted @ 2016-07-17 10:51 看代码`lookdaima.com 阅读(1604) 评论(0) 推荐(0) 编辑