如何去掉最后的逗号
要求输出 例:6 its factors are 1,2,3 我的是6 its factors are 1,2,3, #include<stdio.h>
int main()
{
int n,i,s = 0;
for(n = 2;n <= 1000;n++) //1000之内2-1000
{
{
for(i = 1;i < n;i++ ) //求出因子
if(n % i == 0)
s = s +i; //累加因子
if(n == s) //判断是否是完数
{
printf("%d its factors are ",n); //输出完数
for(i = 1;i < n;i++ ) //输出因子
if(n % i == 0)
printf("%d,",i);
printf("\n");
}
}
s = 0; //s归0 重新开始循环
}
return 0;
}