C语言判断两个数是否为亲和数

欲与妄想   ·  1个月前   ·   编程学习

运行结果:


C#

#include<stdio.h>

main(){

int num1, num2;

int sum(int a);

scanf("%d,%d", &num1, &num2);

if(sum(num1) == num2 && sum(num2) == num1){

printf("%d,%d 为亲和数!", num1, num2);

}else{

printf("%d,%d 不为亲和数!", num1, num2);

}

int sum(int a){

int count = 1;

int ss = 0;

for(count; count < a; count++){

if(a % count == 0){

ss += count;

}

return ss;




0 Reply   |  Until 1个月前 | 56 View
LoginCan Publish Content