神鬼一刀流


私信TA

用户名:clockstream

访问量:2052

签 名:

等  级
排  名 24763
经  验 559
参赛次数 3
文章发表 2
年  龄 19
在职情况 学生
学  校 中国大学
专  业 天文学

  自我简介:

 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

sum+=goal[j];
                j++;
            }
        }
        //judge the sum of factors and p the two values are equal.
        if (sum==p)
        {
            printf("%d its factors are ",p);

            for(int i=0;i<j;i++)
            {
                if(i==j-1)
                printf("%d \n",goal[i]);
                else
                printf("%d ",goal[i]);
            }
        }
    }
    return 0;

}
2019-09-27 21:02:29
#include<stdio.h>
#define NUM 100
int main()
    {
    int goal[NUM];//array for factors.
    int sum=0;
    int N;
    scanf("%d",&N);
    for(int p=2;p<N;p++)//1 and N are not included.
    {
        // sum is different for every number
        // need to be set to 0 individually for every number
        sum = 0;
        int j=0;
        for(int i=1;i<p; i++) // i++ everytime
        {
            //get factors and put them into array.
            if (p%i==0)
            // changed while to if
            // while would keep executing forever
            {
                goal[j]=i;
2019-09-27 21:01:21
  • «
  • 1
  • »