0 like 0 dislike
12.2k views

Write a program that asks the user to type an integer N and find out all the factors of N and display it on screen.

寫一個程式 輸入一個整數N,找出N的所有因數

Example input 1

10

Example output 1

1 2 5 10

Example input 2

24

Example output 2

1 2 3 4 6 8 12 24

 

[Exercise] Coding (C) - asked in Chapter 6: Loops by (5.2k points)
ID: 29831 - Available when: 2017-11-02 18:00 - Due to: Unlimited

edited by | 12.2k views

72 Answers

0 like 0 dislike
Hidden content!
#include ** ** * * *

int main(void)
{

*** * * **** * * *** * * * ***

* * * ** *** * * * **** * **** * * *****
* * *** (a=1; * *** ++a){

* **** **** * * ** (n%a==0){

* * *** ** ***** * * ** * * ** * ** *** *** * * * * *****
** * ** * *** *****
*** * **







}
answered by (-107 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main(void)

{
    int n,i,count=0;

** ** ** * ***** * * * * * * * * * ** **

    for(i=1; i<=n; ++i)
* * * * * ** **** ** * ** * * ** ** ******
* ** **** * *** ** ** *** * **** * *** * * * * * ** *** * **** * (n%i==0)
* * * ** **** ***** * * * * **** * * ** * * ** * *** * ***

*** * ** * * * * * * * * ** *** ** *** * * * *** * * ** *** * (count==0)
**** ** ** * *** * *** *** ** ** ***** * ** ** * ** ******* * * * ** *
* ***** * ** ** * * ****** * *** *** ** *** ** ** * ** ** ** ** ****** * * * * *** * * * ** * * ******
* ** ** * * ** *** * ** * **** * ** *** *** * *** ** * *

* * ** ** * ** ** * * * * * *** * ****** ** * * * * ** ** **** * ***** ****** {printf(" %d",i);}
* * ** * * * **** * * * * * ** * ** * ** * * * ***** *

* * ** ** * * * * * * ** * *** ** * * ** * *** ** ***** ** *** *

* * * *** ** ** *** * *** * ** * ***** **

* ** * * * *** ** * * * *** * * * ** * 0;
       }
answered by (-304 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main ()
{
    int x,y,z,a=0;
* * * ** ** ***** * * * ***** * ** * * *
    for (y=1;y<=x;y++)
    {
* * ***** **** *** * * ** ** ** * * *
*** * * ** *** * ** ** ** * * * * * (z==0)
* ** * *** *** *** * * ***
*** * ** *** * **** * *** * * * * (a==0)
* ** ***** * * * **** ** * ** * *** **
*** * * * ** * ** ** * ** * ** ********* **** * * * *
*** * ** * * ** * ** ******* * ** * ** * * ***** ** * **
* * * ** *** **** * ** * * * *
** ** *** * * ** ** * * *** **** ** *** * * ** * **** **** *
* * **** * * *** ** *** *** ** * ** **** * * * * * **** * *
*** *** ** ** *** ***** ** *** * **** * * * *** ******* ** ** * %d",y);
* * * * ***** * ** * * *** * *** ** * * *** * ** * * ***** ** ** *****

*** *** * ** * **** * * * * * ****

* * ** *** * ** * ** ** ***

}
answered by (-229 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
    int i,n,c;
* ** * * **** * * * * ***** *** ***** *
    for(i=1 ; 1<=n ; i++)
*** * *** *** ** *** * ** **** * * * ** ***
** ** * * ** * * * * * * * *** * ***
*** ** * **** *** * * ** * * * * ** *** ** **
        {
** * * * * ***** *** * * * *** * **** **** * *** * ** *** * *** ** **** ** *
** * *** * * ** ** * *** * * ** * * ** * ***** ** ** **** *** *** ***
******* ** * ** * ** ***** * * ***
**** * * ** **** *** **** * **** ** * ** * ** *
* ****** ** ** * * ** * ** ** ****** ** ***** * ** ** * ** ** **** **
* ***** ** * * * * *** * ** * ** * * * ** * **** ** *** **** * *** **** ** * * %d",i);
*** * * *** * * ***** * * ** * * ***** *** **** * * * *
* * * * ***** ** ** ** ** *** ***** ** * * **
}
answered by (-323 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
    int m, n;
    int a=0;
*** * * * * ** ** ** ** ***** *** * * *** * * * *** ** * *** ** *** * *
* ** * * ** ** * ***** *** * ** * n <= m; ++n)
    {
* * *** ** *** ** ** ** ***** * * * ** ** ** (m%n == 0){
** * *** ** * * * ** ***** ** * * * * * *** * * * * * ** ******* *** * **  (a==0) {

* ** *** ** ** ** * * ** * **** **** * * * * *** ** *** * **** * * *** *** *
**** * *** * * ** ** * ** * **** *** * ** * ***** **** *** * * *** * * * *** * ** * * * * **** ******** ** {
* *** * *** **** * * * * * * **** * ****** * * * ** ***** * ** ** * **** * * ** *** ** ******* *** * ** ** *** ");
*** ** * *** * * *** * * ** * * ** *** * ** ** * * ** *** * * **** * ***** *** *

* * **** ****** ** ***** *** * * *** * * * * * *** ** *** * ****** * ** * * *
* * * * * *** * *** *** ** *** ***** * * * ** ** ** *** * * * * ** * * ***** * ***** ** ** * *** **
** *** ** ** * * * ** *** * * * **** * ***** ****** * **
    }



    return 0;
}
answered by (-254 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
    int N,a=1;
* * ***** *** *** * * * * * ***** * * **** **
** ** ***** * ** * * ** *** ***
    {
* * * * * ** * ** * * *** **** ** * * * * *** *
*** ** *** * * * * **** * *** * *
**** **** * **** *** * * ** *** ******** ** ** * * ** * * *** ***** *
******** * * * * ** *** * ** * *** ******* * * ** ** ** *
* * * * ** ** ** * **** ****** ** **** ** ** ** * * ** *** * ** *** ** *** * ** ** * * ");
**** ** * * * * * ***** * *** * * *** *

* * * ** ** * * ** * **** ***** ** ** * * **


    }

*** * **** ** * * 0;

}
answered by (-281 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
****** * **** ***** *** N,a=1;
** **** * *** **** * * * **** **** ** * * *
* *** ** ** *** * **** * * ** * * **
    {
** * *** *** ** ** * *** * * * ** * * * * *
* * * * **** * ***** ** * * **** * *
** ***** * ******** * * * ******* * ** ** ** *** *** * ** *
** ** * * ** *** ******* ** ** * * ** ** * **** ***** ");
* * * * ** * * * ****** *** * * *** ** *

*** ** ****** * * * ** * * ** * * *** * ** **


    }

*** ** * * * * **** ** 0;

}
answered by (-281 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
int a,b,c=0;
int space=0;
scanf("%d",&a);
  for(b=1;b<=a;b++)
  {

* *** * * ** * * ** * * * * ** * ** *** *
** ***** * ** * ** ** *** * * * * * ***** ******* * * * * * * ** * *
** * *** ** * **** *** ** * * * * * * * * ** * *** * * * * * * ** * * * * *** * * * * * *
* *** *** ** * *** ** * * * * * ****** *** * ** * ** * * * * *** * ** *** ***** ** *
* * * ** ** **** * * ** * * ** * ** * ** ** ** * * * * ** * * **** * * ** *** *
* * *** ** * * * *** * * * * * * * ** * * * * *** ** * * **** ***
** *** * ***** * ***** * **** ** * *** * * * * * *** * * ***** ** ****** ****** * ** %d",b);
** * *** ****** ** * ** ** * * *** * * * * *** * * ** * * * ** * * * * ***
**** * **** * ***** ***** * ** ** * ** * ******** ****** ***
        }

  }
}
answered by (-329 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main ()
{
* ** ** ** * ***** * * n,i;
** * * *** * * * * * * * * ** ***** * * * * * *

** ** ** * * * * * * * * ; i<n ; i++)

** * *** * * * * **** * ** * ** * * * ** (n%i==0)
**** ** *** * ** ***** * * ****** * * ** * ** ** ** ",i);
* **** ** *** **** ***** ** **** **
** * * * * * ** 0;
}
answered by (-196 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
* * * * ** * * * ****** ** * N,a=1;
* * ** * *** ** ** * * ** * * * ** * *
* ***** ** * * * * *** * *** * *
    {
** ** * ** ** ****** * * ** * *** ** ** **** * *
* * * ** * *** ****** * **** **** * ** ** *
* ** ***** * *** * * * * ** *** *** ** * ",a);

* * * ***** ** *** * **** ** ** *** *
* * * * *** * **** *** ** * **** ** ****** * * * **** **** * *


    }
* * ** *** ** * ** 0;

}
answered by (-281 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.130.53
©2016-2025

Related questions

0 like 0 dislike
99 answers
[Exercise] Coding (C) - asked Nov 2, 2017 in Chapter 6: Loops by semicolon (5.2k points)
ID: 29829 - Available when: 2017-11-02 18:00 - Due to: Unlimited
| 17.5k views
1 like 1 dislike
85 answers
[Exercise] Coding (C) - asked Oct 26, 2017 in Chapter 6: Loops by semicolon (5.2k points)
ID: 28914 - Available when: 2017-10-26 18:00 - Due to: Unlimited
| 15.4k views
0 like 0 dislike
69 answers
[Exercise] Coding (C) - asked Oct 26, 2017 in Chapter 6: Loops by semicolon (5.2k points)
ID: 28913 - Available when: 2017-10-26 18:00 - Due to: Unlimited
| 11.8k views
12,783 questions
183,442 answers
172,219 comments
4,824 users