0 喜歡 0 不喜歡
2.9k 瀏覽

Write a program that get the input of two integers n and m(n < m). Find out all prime numbers between n and m (not include n and m), then display them on the screen.

寫一個程式 輸入兩個整數n和m (n < m),找出所有n到m之間的質數(不包含n和m)。

Example input 1

1 10

Example output 1

2 3 5 7

 

Example input 2

10 20

Example output 2

11 13 17 19

 

[練習] Coding (C) - 最新提問 分類:Chapter 6: Loops | 用戶: (5.2k 分)
ID: 29829 - 從幾時開始: 2017-11-02 18:00 - 到幾時結束: 無限制

修改於 用戶: | 2.9k 瀏覽

99 個回答

0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int x, y, flag, i;

** ** * * ** ** * * ** * * %d", &x, &y);

* * ** ********* * **** * ***
    {
* * * *** * * * * * * * * * * **** **

*** ** ** ** * * * * ** * ** * ******** ** i <= x/2; i++)
**** ** * ***** * * * *** * * ****** * * ** ****
* * * ** * * *** * **** **** *** * ** *** *** ** * == 0)
* ** * ** ***** **** ** * ***** * * * * * * ** * ******* *** ******
** * * ** * ** * *** * *** ** ** * * * **** * *** **** * ****** *** * * * ** * * ** *
*** * * * * ** ** **** * * ** * **** * **** ****** * *** **** * * * * * *
* ** *** * * * * * * ** ** ** * ***** ******* *
*** ** *** * * ***** * **** ** ******* * * **
** **** * * ** * **** *** **** ***** * ** **
*** *** *** **** * * * *** ** ** **** **** ** **** * * * ** * * ** *** * * ******** ", x);
** ** * ** ** ** * ** * * * * *** ** * *
    }
* ** * * * ** ***** * 0;
最新回答 用戶: (-168 分)
0 喜歡 0 不喜歡
內容已隱藏
#include <stdlib.h>
#include <stdio.h>
int prime(int i)
{
** * * *** *** * * * k;

*** *** * ****** * *** *** *
    {
*** * * * * ** * ** * ** * * *** * * *
* ** ** ** * *** **** ** * ** ** 0;
    }
* * *** * * * **** * ** * 1;

}

int main()
{
** *** * ** * **** ** n,m;
*** * ** ** * * *** *** * * %d",&n,&m);

*** * ** * ** *** * i,first;
* * **** * * * ** ***** * *
*** * **** * * ** *** ** ***** ** * * **** *** *
* ****** * * ** * * ** ** * * ** **** * *

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

* * * ** ** **** * ** ** * w=first+1;

** **** * ** ** * *** ** * ****** **
* ** ** **** *** * ** *********** * ** * *** * ** **
** * * *** ***** **** **** ****** *** * * * * * ** * ** * ********** * **** * * %d",w);





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

}
最新回答 用戶: (-16 分)
修改於 用戶:
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Correct output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
int main()
{
    int i,n1,n2,c=0;

    //enter the two number intervals
    scanf("%d %d",&n1,&n2);

** * * ** ** ** * * * ***** * ** *
    {
* ** ** *** *** * **** * * * ** ** j;
* ***** *** * ******* * * ** * *** ** * **** * * * * ** * *
**** ** ** * * * ** ** ***** **** * * ** *
***** * *** * ***** ** * * * **** ** ***
* ** ** * ** * * *** * ***** *** * * ** * * ** *** * * ** *
** * ***** *** *** ******* * ** * **** *
***** ***** *** * ** * ** ****** ** * * *
*** * * **** ** ** * * * * **** **
* **** ** ** * ** ** *** * * *** ** ***** * * * *** * ** ***
***** * * * *** * * ** * * *** **** * * ** ** * * * * * ***
** * **** * ****** * * ** * ** *** ** ** * * * * * * * * * ** ** **** ** **** *** *** * ** *
* * * **** * * * * * * * **** ***** * **** ** * * * ** ** *** *** *** ** ** ** ** * * *** ** * **
*** *** ** * * * *** * ** ** **** **** * * * * ** * ** **** **** ** **
** *** * * ****** *** * **** *** ** * ** ** * * * **** * ** *
** *** *** ******** ** * ** * ** * ** * * *** * * * ** * **** ******
* **** **** * * ** ***** ** * * * * ** * * * * * ** * ** * * * * ** * ** * %d",i);
* ** * * * **** * * **** ** * *** * * ** * * ** ** *** * **
**** ****** * **** * ** * *** * ** ****
    }
    return 0;
}
最新回答 用戶: (-167 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>

#include <math.h>

void main()

{
    
* * * **** **** * ** * num,m,n,d;
    
* * ** ** * * * * ***** ***
    
** * * * * * * * * ** * * * ****** ** ** the Range Between m,n ");
* *** *** * ** ** * *** *
* ** ** ***** * * * ** * * ** * ** ** * &m,&n);
** * ****** *** **
** ** * * * ** * ** (num = m; num <= n; num++)
    
* * * *** * ** * * * * ****
** ** * *** ** ** ****** **** * *
**** *** *** * * * ** * *** **** * *** ***** * * * * * = 2; d < num; d++)
* *** ** *** * * ********** ** * ******* ***
** * ** ** **** ** ** ** ** ** ** * * * *
* * * * ** * * * *** * * * * ** * * * * *** * * * *** * *** * * *
* * ** *** ** ** ** * * * ******* * * * * * *** * * *** * *** ***** * (num % d == 0)
* * * * * * * * **** * *** * *** * ** ** * * ** **
* * * * * ** *** ** **** *** * ***** * * * ** ** *
*** * * ** * * * ** * * * ** * *** * * ***** * * * *
**** ** * * * *** ** * * ** ** ** ****** **
*** * * * ** * *** * * ** * * **** *** * **** **
* * * * *** ** ***** ** **** * *** * * (d == num)
** **** ** * * ** **** * * * *****
** * ***** **** * ** *** * * *** ***** ***** ***** ", num);
* ** * * ** *** ** * * ***** * ** ** *
** * ** ****** *
** * ** * ******* **
*** *** ** * *** * ****** ****
** * * * * * * * * ** *** 0;
    
}
最新回答 用戶: (-108 分)
0 0
prog.c: In function 'main':
prog.c:11:5: warning: implicit declaration of function 'clrscr' [-Wimplicit-function-declaration]
     clrscr();
     ^~~~~~
prog.c:37:5: warning: implicit declaration of function 'getch' [-Wimplicit-function-declaration]
     getch();
     ^~~~~
prog.c:38:12: warning: 'return' with a value, in function returning void
     return 0;
            ^
prog.c:5:6: note: declared here
 void main()
      ^~~~
/tmp/cchS0WoB.o: In function `main':
prog.c:(.text+0x1d): undefined reference to `clrscr'
prog.c:(.text+0x9a): undefined reference to `getch'
collect2: error: ld returned 1 exit status
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>

#include <math.h>

void main()

{
    
* * * * ** ** * *** ** * * num,m,n,d;
    
* * * * * ***** *****
    
* *** **** ** * * ** * * * ** ** the Range Between m,n ");
** * *** * * * *
** * * * ** **** ** ** * *** ** &m,&n);
*** *** *** ***** ** *** * *
* * *** * * * ** (num = m; num <= n; num++)
    
** **** * * * *** *
* **** * ** ** * * * * * *** * * ** ****
**** * * ***** * * ** * * ** * * * = 2; d < num; d++)
*** *** ** * ** * ** ** * * * **** *
** * * **** * ** * *** * **** ** *
** * * *** ** *** ** * * **** *** * ** ** ** ******** *** ***
*** *** ** * **** ** * * * * *** ** * ** * *** ** ** **** * * * ** * (num % d == 0)
* * ** * * * * ** *** ** * * **** * * * ***** ** * ***** *
* * * ****** * ** * *** ****** *** * * *** ** * * * * **** * **
* * *** *** ** * ** * ** * * ***** ** ** * **** **** *** * * *
***** * **** *** ** ** * * * * ** ** * ** * ***** **
* ** * ** ***** *** * ** *** *** *** *
* *** * ** * * *** * *** ** * ** * ** * (d == num)
* * *** ****** * * ** * * * * * * * ****
* * ****** ** **** * * ****** ** ** ** ** ** * * ", num);
* ** * * * * * * * * ** * * ** * *** * **
** ** * *** ** * **
* ** * *** ***** ** ** * *
* * * ** * * * * * **
** *** ***** * * **** **** ** * * 0;
    
}
最新回答 用戶: (-108 分)
0 0
prog.c: In function 'main':
prog.c:11:5: warning: implicit declaration of function 'clrscr' [-Wimplicit-function-declaration]
     clrscr();
     ^~~~~~
prog.c:37:5: warning: implicit declaration of function 'getch' [-Wimplicit-function-declaration]
     getch();
     ^~~~~
prog.c:38:12: warning: 'return' with a value, in function returning void
     return 0;
            ^
prog.c:5:6: note: declared here
 void main()
      ^~~~
/tmp/ccb4hr0F.o: In function `main':
prog.c:(.text+0x1d): undefined reference to `clrscr'
prog.c:(.text+0x9a): undefined reference to `getch'
collect2: error: ld returned 1 exit status
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>

#include <math.h>

void main()

{
    
*** ** * * ** ** ** num,m,n,d;
    
**** * * *** * *
    
** * ** * * ** * ** * * *** * * *** the Range Between m,n ");
* ** ** **** * ** **
* * *** ***** *** * ** * ** * * *** &m,&n);
** * ** *** * * ** * *
***** * * *** ****** * (num = m; num <= n; num++)
    
* * *** * * ** *
******* * * **** * * *** ***** * * * * ** * ** **
* * * * * * *** **** * ** * * * ** * *** * = 2; d < num; d++)
*** ** ** ** * * ** * * * * ** *
* ** * ******* ***** * * *** * * * * **
* * * *** ** ******* * * * * * **** ** ** * * *
*** *** * ** ** *** * * ** ***** * * * ** * * * * * ** (num % d == 0)
** ** * ***** * ***** ******** * * * * * **** ** * ** * **** ** *
* **** * * * * **** * ** ****** ** *** ** * * * *** * *** ** ** **
* * ** * * * ** * * ** ** * * ** *** * * * * *** *** * * **** ****
* *** * **** * **** *** * * *** ** * ****
**** ***** * ** **** ***** * ** **** * ***
* * *** ** *** * * * * * * * **** * (d == num)
* ** *** ** * * ** ******** ** * * * * **
* * *** * ** * ***** * ** * ** * * * * * * *** *** *** ", num);
**** ** * ** * ** ** **** *** ** * * * *** *
* *** * ***** * * *
* * ******* * * * * * **
* ** * ** * ** * ** ** ** *
** * ** * *** **** 0;
    
}
最新回答 用戶: (-233 分)
0 0
prog.c: In function 'main':
prog.c:11:5: warning: implicit declaration of function 'clrscr' [-Wimplicit-function-declaration]
     clrscr();
     ^~~~~~
prog.c:37:5: warning: implicit declaration of function 'getch' [-Wimplicit-function-declaration]
     getch();
     ^~~~~
prog.c:38:12: warning: 'return' with a value, in function returning void
     return 0;
            ^
prog.c:5:6: note: declared here
 void main()
      ^~~~
/tmp/ccmKIGDf.o: In function `main':
prog.c:(.text+0x1d): undefined reference to `clrscr'
prog.c:(.text+0x9a): undefined reference to `getch'
collect2: error: ld returned 1 exit status
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
int num_is_prime(int x)
{
** * ******* * ** **** y;
* * ** * *** * ****** ** ** ** * ** *
    {
** * **** * * ** * ** * * **** *** *** * * ** ** *
** * *** ** * * *** ** * * ** ** * ** ** * * *
***** * ** * * * * ** ** * *** ** **** *** * ****
    }
* ** * ** ****** ****** *******
    {
*** * ** * *** ** ***** *** * ** ** **** 1;
    }
** * *** *** ********* *
    {
** * *** * * * **** * ***** * *** * * 0;
    }
}
int main()
{
* * * ***** *** * * * * * a,b,f=1;
* * ** * ******* ******* ** %d",&a,&b);
* ** * *** ** * *** **** * * *** *
* * ***** ** **** * *
****** **** * ** ** * ***** *** * * * *
** * *** * * * ** * **** * **** ** * ** * * **
* ** **** ** *** *** *** ** * ** * **** ***
*** * ****** **** * *** ** ** ** ** **** * * ** * ** * ** * *** ** * *
*** *** ** ** * **** ** * * * * * * ** ** ***** * * ** **
* * * * * **** ** * ** ** ***** ***** ** ** * *** ** * ** *** * * ** * * * ******* ** * * ** ** ");
* * * * * * ** ******** ** * *** ** ** ***** ** * * * * **** *** * ***
**** * ** * *** * * * *** ** * * * * *** * ** * ***** * * * * * * ** ** *
** * ** **** ** ** * ** * ** ****** **** ** ** ** * **** ** **
*** * * * **** ** * * ** ** ***
    }
}
最新回答 用戶: (-255 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
int num_is_prime(int x)
{
* * **** * *** ** * ** y;
* * * * * *** * * * * *** * ****
    {
** * *** **** * ** * ***** ** * ***
** ***** ** ********* * * * * **** * * ** ***
* *** *** ******** * * * ** * ** * * ** ** ** ** ** ** * *** **
    }
* ***** * * * ****** ***
    {
* * * * *** *** * * * * * *** **** *** 1;
    }
* * * * * * * *
    {
** * *** ** * ** ** **** * *** ** *** ** ** ** * 0;
    }
}
int main()
{
* *** * ** * *** * *** a,b,f=1;
* * ** * ** ** ***** **** * * * %d",&a,&b);
** ** * * **** ** *** * *
    {
* * * * **** ** **** * ** ** * *** **** ** * * ***
** * *** *** * * ******* * * ***** ****** **** * ***** * *** *
* ** ** * ***** ** **** ** * ** *** * *** ** *
* * ***** ** ** * *** * * * ** ***** *** ****** * * *** *** **
* * **** ** ** *** * * * **** ** **** **** * ** * * * *
* * *** * * * * ** * ****** * * ******** * ** * ** * ** * ** **** ** *** * * *
* ** ** *** * ** * **** * ****** *** * **** ** ** *** *
** ******** * ** * ** *** * *** ****** ** ** * ** * **** *** * * * * * **** * * ** *
** * * *** *** ** ** ** * * **** * * * * *** * * *** * *
* * * *** * ** *** **** **** *** * *** * * ** ** *
    }
}
最新回答 用戶: (-255 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>

int main()
{
 
    int i;
    int n;
    int m;
    int flag;
    int count=1;
   
    scanf("%d%d",&n,&m);
    
    if (n<m)
    {
        for(n=n+1;n<m;n++)
        {
* * * ** * * **** * ** * **** ** *** * * * ** * * * * * **** ***
* * ** *** *** * * * * * *** * * ** *** * * ** * * ***** * ** * *
** ** * *** ** ** ******* * ***** *** ** *** * ** * * * * ** * * *** * * * *** *
****** * * ***** *** *********** ** * ** ** *** ** *** ** ** * * ****** * ** *** ** ** * *
* *** * *** * **** *** * ******** ** * * * * ****** * *** * ******* * ** * * **** ** (flag==0 && n==i)
**** ** * * * ** *** * ** *** * ** * * ** **** ** * * ** * *** * * * * ***
** ** * * *** ** *** * * ** ** * ** * ** * * * * * *** *** * ** **** * ** * ** *** ** * * ** == 1)
******** * ** * **** * ***** * * * **** * * **** * * ** * ***** ******* ** **** *** * ** * *** *** *** * * ** **** *** *
* * ** ** **** * ** ** * **** *** * *** ** * * ** **** * * **** ** * ** ** ** ** *** *** * * * * * ** * *** ** * * * n);
* **** ** ** ** * ** **** ** ******* * * ** * ******* * ** ** ******* * * * * * * **** * * * * ** ** ** * * *** * * * ** * *** **
* ** **** * * ** * ** * ** ** ** * **** ** * *** * * * * * * * *** ** *** * * * * ***** ***
** ******* * * * ****** ** ** ** ***** ** * * ***** * ** * ** ** * ** *** * ******* *** * ** ******** *
**** * ** * * ** ** ***** * *** * * * * **** ** * ** * * * * * * * ***** * ** *** ** * ** ** ** ** * ** ****
* * * **** *** * * **** * ** ***** **** * * * * * **** * * **** **** * * ** *** * ** ** ** *** ** **** *** * * **** * ** %d", n);
***** *** * * ** * ** *** * ****** ****** *** ** **** ** * *** *** * ***** * * *** *** ** *** ***** ****** *** * * ** ** **
** ** ** ** *** *** *** ** ** ** * * ******* * *** * ** * **** ** *** * ******** * ***** * * * * ** * * * ** ** * **** *** ** ** *** *
* ***** *** *** ** * * * ** * * * *** *** ** *** * * * * *** * *** * ** ** * ***
**** * ** ****** *** ** * * *** ** * *** * ** * * * * * * *** ** * * *** **** * * * * * * * *** **
* *** * ** ** *** *** *** * ** * ** ** * * * **** *** * * * ** ****** * ***** *
** *** *** *** * *** * ****** *** *** ** * *** * * ****** ***** *** ** * *** **** **** (flag==0 && n!=i)
* * * * * * * ** ** ** *** *** ** ** ** ** ** ** ** * **** * * * * *** ** ** ** **
** ** * * **** *** * * ** * **** * ** ** * ** * *** * ** *** *** ** * ** * ** * ** * * **
** *** *** * ** ** * * *** **** *** ** *** * * ** ****** * **** ***** *** ** * * * * ** ** *** * * ** *
*** ***** ** * ** * * * * *** ** * *** **** *** * * ** ** ** ** * ***** **
** * ****** * ****** * * **** *** ** **** * * ** *
        }
    }
    
   
   
    return 0;
}
最新回答 用戶: (-284 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>

int main()
{
 
    int i;
    int n;
    int m;
    int flag;
    int count=1;
   
    scanf("%d%d",&n,&m);
    
    if (n<m)
    {
        for(n=n+1;n<m;n++)
        {
******* * ** ** * ** * * ** ****** **** *** ** * * ** * **** *** * * *
*** * ** * ** * **** **** * * *** *** ** * ** ** * ** ***
* * * ***** *** * * ***** *** * ** * * **** * * * * ***** * **** * *** * * ** *
* ** *** ** * * ** *** * **** * * *** *** *** *** * ** *** * * * ******* **
* **** *** ** ***** ** * * ** * * ** * ** * **** ** * * ** * * ** * ***** *** * * * ** ** * * (flag==0 && n==i)
** ** ** * * **** * * ***** * ***** ** ***** * ** **** * *** ******** ** ***** *** * **** ** *
** * * ********* *** * * ** * *** *** * * **** * * *** * **** *** ** *** * ** * ** * *** *** * ** *** * * *** == 1)
*** ** * * * * * ** *** **** **** ** * ** * * *** * * * *** ***** * * **** * ** **** * *** ** * * ** ** *****
* ** *** ** * * *** *** *** ***** * * * * * * * ** ** ** ** * ****** *** ****** **** ** * *** * ** **** * ** * ** * **** n);
** ** * ** ** ** ** ***** ***** * * ** *** * * ** * * *** ** ** *** * * * **** ****** *** ** *** *** * * ** * * * *** * * ****
* * * * ** ** * *** * *** **** * ** ***** ** * ** ** * ***** **** * * * * **** * * *** ** *
* ** **** * * ** * * ** * ** * ** * * * * ** * ** * * *** * ***** * * ** *** * * *** * *** * * ** *
** * *** * * ** * ** * **** * * ******* **** * ******* ** ** * * * * * * * * * * ***** * * *
** ** ** * * * * * ** * * * * * **** **** *** * * * ** **** ** ** * ** **** * ** * * * ** * **** ** * * ** * * ** ** ** * * ** * **** %d", n);
* *** * ** * *** ** * ** ** **** * * * *** * ****** *** * **** ** * **** ** * ** ***** * *** *** ** * * * * ** ** * * * * *****
* ** * **** **** ***** ** ** ** * * * * **** * ***** **** * ******* ** * ** ** * *** ** ** *** * *** * ** * ***
* * ***** ** * ** ***** ***** ** * ** ** * * ** * * ** ** * ** ** ** * * **** ** ** ** * ****** ** *** * ** **
* **** ** **** ******** **** ** ** * * ** * *** ** * * * * * ************** ** ** * **** ****** * *** * **
* ** ** ****** * **** * * *** * * * * * ** *** * ** ** *** ** ***** *** * * * * *
* * * * * ** * * *** * * * *** * ***** *** * * *** ** ** ** * *** * ** * *** ** * (flag==0 && n!=i)
* * ** * ** * * ** * ** * * *** ****** * * ** ** *** * *** ***** * * **** *** *
* * * * * ******* * * *** ** * * ** *** * * * * ** * * *** ** * ** ** * ** ** *** * * * * **** ** * ** * ** *
* * ** *** * ** ** * ** ** *** * ** * ** *** * * ** ****** * ** * * **** ** ** ***** ** * *** ** * ** * ***
**** ** ** *** ** * * ** ** ** *** ** *** ******* *** * ** * ** * ** *** ** * * ***
* ** ***** * * ** * * *** ** ** * * **** ** *** * * * ** *
        }
    }
    
   
   
    return 0;
}
最新回答 用戶: (-193 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:108.162.216.228
©2016-2024

相關問題

0 喜歡 0 不喜歡
72 回答
[練習] Coding (C) - 最新提問 11月 2, 2017 分類:Chapter 6: Loops | 用戶: semicolon (5.2k 分)
ID: 29831 - 從幾時開始: 2017-11-02 18:00 - 到幾時結束: 無限制
| 2k 瀏覽
0 喜歡 0 不喜歡
93 回答
[練習] Coding (C) - 最新提問 11月 2, 2017 分類:Chapter 6: Loops | 用戶: semicolon (5.2k 分)
ID: 29830 - 從幾時開始: 2017-11-02 18:00 - 到幾時結束: 無限制
| 2.4k 瀏覽
12,783 問題
183,443 回答
172,219 留言
4,824 用戶