2025-03-06 22:45:14 +08:00

25 lines
446 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*-------------------------------------------------------
输入一个整数输出该数所有因子1和它本身除外之和。例如6的因子有2和3则输出5
(注使用for循环
-------------------------------------------------------*/
#include <stdio.h>
main()
{
int n,i,s;
printf("请输入一个整数n");
scanf("%d",&n);
s=0;
/**********Program**********/
for(i=2;i<n;i++){
if(n%i==0){
s+=i;
}
}
/********** End **********/
printf("s=%d\n",s);
}