快乐学习 一个网站喵查铺子(catpuzi.com)全搞定~

完全数,又称完美数或完数(Perfect Number),它是指这样的一些特殊的自然数,它所有的真因子(即除了自身以外的约数)的和,恰好等于它本身。例如,6就是一个完全数,是因为6 = 1 + 2 + 3。请编写一个判断完全数的函数IsPerfect(),然后判断从键盘输入的整数是否是完全数。注意:1没有真因子,所以不是完全数。代码如下,按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。#include  #include  int IsPerfect(int x); int main() {     int m;     printf("Input m:");     scanf("%d", &m);          if (_________________)  /* 完全数判定 */         printf("%d is a perfect number\n", m);     else         printf("%d is not a perfect number\n", m);     return 0; } /* 函数功能:判断完全数,若函数返回0,则代表不是完全数,若返回1,则代表是完全数 */ int IsPerfect(int x) {     int i;     int total = 0;          /* 1没有真因子,不是完全数 */          for (__________________)     {         if (___________)             total = total + i;     }     return total==x ? 1 : 0;      }

中国大学MOOC答案 数据帝 2024-04-09 扫描二维码

A、第10行:   IsPerfect(m)第24行:   i=1; i<x; i++第26行:   x % i == 0
B、

第10行:   m

第24行:   i=1; i<=x; i++

第26行:   x % i != 0
C、

第10行:   IsPerfect(m)!=1

第24行:   i=0; i<=x; i++

第26行:   x / i == 0
D、

第10行:   IsPerfect(m)==0

第24行:   i=0; i<x; i++

第26行:   x % i != 0
喵查答案:第10行:   IsPerfect(m)第24行:   i=1; i<x; i++第26行:   x % i == 0

喜欢 (0)
关于作者: