0 like 0 dislike
13.3k views

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

 

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

edited by | 13.3k views

99 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>
int main(){
    int a,b,c=0;
** ** *** * ****** * ** ** * %d",&a ,&b );

* * ** * **** * ** * * i=a;i<b;i++){
*********** * * ** ** * ** * * ** * * * j=2;j<=b;j++){
******** * ** * ***** * * ******** * **** * * * * ****** * * ** * && i%j==0) break;
**** ***** ******** * ** * * ***** **** * * * *** * ** * ** ** if(i==j){
* * ** * * * ** ***** *** * ****** ** **** * * * * ** *** * * ** *** * * *** * * * ** ** *
* ** * * ** * * *** * * ** * *** *** ** ** * * ** **** ** * * **** * * ** ** ***** * * * * ** ** * * * * * ** * * * *** * **
* * * * **** * * ** * * *** * * *** * * ****** ** * * * **** **** ** * * ** * * * *** * * ** * * **** ** ***** *** * *
* ** *** ** ** * * ** ****** * * *** ** * * *** * ** ** ** ** * * * * *** ** **
*** *** ** ** * * ** * * * *** ** ** * * * * *** * *** **** * *** * *** **** * ** * * printf(" %d",i);
** ** ******** * ***** * * **** * *** * * * ** **
** *** * ** * ** * *** * ***** *

    }

    return 0;
}
answered by (-116 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
*** ** ** ** **
* * *** ** * *
* *** * * * ***** ***

int main()
{
int i,n,m;
*** * * ** * ** *** *
* **** * * *** ****
** ** ** * **

{



** **** * * * ** ****
{
* *
** *
}
* **** ***

**


* * *** ** ** * *


}}
****** 0;
}
answered by (-336 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!
* ******* *** * *
***** *** ** ******
* * * *** * * * *

int main()
{
int i,n,m;
* ** * * *****
* ** * * ** * *
** * * *

{



***** * * * ***
{
* **
* *
}
* * *

*


** ** ** * *


}}
** 0;
}
answered by (-336 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;
** * ** * *** * * * * *** ** %d",&a ,&b );

**** *** ****** ** i=a;i<=b;i++){
* ** ***** ** * **** ** * ** * * * * ** j=2;j<=b;j++){
* * * ** **** * * *** **** **** *** * *** * * * ** ***** * * * * && i%j==0) break;
* * * ** ** * ** * **** ** * ** *** *** *** * *** * *** * ** * * if(i==j){
* * * ** * ** * * ** * ** * * **** * *** * * * * ** * ** ** * *** *** *
* * ** * * * ***** ** * * * * ***** * * * ** * * *** * *** *** ***** ** *** * * ** * * ** * * ***** **** ** ** * *** ** *
* **** * * ****** ** *** ** ** **** ** *** * *** * **** * * * ** ** * * * * * ***** * ****** * * ** * * * * *
* * ** *** ** ** * ******* * *** *** * ** * * * ** * * * * * * * **** * **
* **** *** ** **** ** *** ** ** * * * **** *** * * **** ***** * * *** *** * * ****** *** * printf(" %d",i);
**** *** ** ** ** **** **** ** ** * * * *** * ** ** * ** **
**** * * *** * ** *** * ** * * * * *

    }

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

** ** ** * * * * ***** i=a;i<=b;i++){
* ** * * ** ** *** * ******** ****** * ** j=2;j<=b;j++){
* ** * ******** * * * *** * ** * ** *** *** * **** * ** * * ** && i%j==0) break;
***** *** *** * * * * * ** *** ** ** ** * * ******* ***** if(i==j){
*** * * * * ********* ** * * *** ** *** ** *** * * ***** * ** * * * **** ** **** * ",i);
** * * *** ** * * ** ** ** ** ** ** ** **** *** * * * *
** **** * * ** * ***** ** * ***** * * * *

*** ** * *** * ***
** * * ** *** * * 0;
}
answered by (-116 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!
* * * * * * ***
*** * * *** ****
int main(){
* ** ** * ** *** a,b;
* * *** * * * * * ** **** * * ** * **** * * ******** ** ,&b );

** * * ** * ***** *** i=a;i<=b;i++){
* ** * * *** * ** ** * * * **** ** * j=2;j<=b;j++){
** ** ** **** ** ** * * ** * *** ***** ****** *** * * * * * ** * * && i%j==0) break;
** ** ***** * ** ** * * ** ** * * * * * * * * * **** *** if(i==j) printf("%d ",i);
* * **** * * * **** *** ** * * ***
* * *** * ** ** * **
* * * * *** ** **** 0;
}
answered by (-116 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>
#include <stdlib.h>

int main()
{
** * ** * * * * * m, n, divider, prime[100], cnt=0, i=0;

****** ** *** * ** * ****** * *** * ** %d", &m, &n);

* ** * ** *** * * * **** = m + 1; m < n; m++)
* * ****** **** * *
***** * ** * **** *** * * * *** ** ** *** *** *** *** = 2; divider < m; divider++)
* *** * * * * * * ** *** * ** * ** *
* ** ** ** * * * * ** ** * * * * **** * * * * *** **** *** * * ** *** % divider == 0)
**** * ** *** ***** * ** * * ** * * * ** *** * **** * * ****** ** ** * **** *
*** ** ** * *** * *** *** *** **** ** * *** ** *
*** ** ****** ** *** * ** * **** ** ** * ** *** * == divider)
* **** * ***** ******* ***** * ***** * * * * ** *
** * **** * *** * * * * * * * **** * ***** * ** ***** ** *** ** = m;
* *** * *** * ** *** ****** * * ** ** **
** * ** * *** *
* * **** * * ****** * ** * i<cnt;i++)
****** **** ** * * ** *** *
* ** * * *** ***** *** * * * ** **** * * * ** ** *** ** * * prime[i]);
* * *** * * ****** * **** * ****** +1 < cnt)
* * * * ** ** ****** ** *** * * * ***** *** * * ** * * * * ***** ******* ");
    }

*** **** * ** * **** ** *** 0;
}
answered by (5.2k points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 0
Nice haha
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
    int n,m,i,j,k;
    scanf("%d %d",&n,&m);
* * ** **** ** * * *** * ** ** ** *
* ** * * * * * ** * * **** * * * ** * ** **
** *** *** *** * *** * *** * *** ** *** **** ** **** * ** * * *
**** ****** ** * *** ** * * ** * ** **** * * * * * * ****** *** * * * *************
* ** * * *** * ***** * ** * * ** **** **** * ** * * ** * * * *
** * *** * * * * ** * * * * * ** * * ** * ***** ** * *** * *********** *** * *** * ** * *** ",i);
********** * * * * * * ** * **** ** * *** ** ** ** ** * ** * * ** * ** * ** * * *
** ** *** * * ** * ** * ** ** ** * * ***** **** * * *** *
* **** * **** **** * * * * * * * ** * *** *** ** ** ** ** * * * ** if(k==0){
***** * ** *** * ** *** **** * ** * * ** * ** * ** * * *** * ** ** * * **
* * ** ** * * * * * * ** ** * * **** * *** *** ** **** *
*** * * * * ** ** * * ********** * * * * ** **
    }
    return 0;
}
answered by (54 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 i, a , b;
int flag;
scanf("%d ** *** * *** ** * ,&b);

for * * * *
{
** *** ** * ** * * *** ** * is testing\n",i);
** * * * *** * ** *** j=0;
** * * * * * * ***** * = 1;
* * **** *** * * (j=2;j<i;j++)
* ** ***** ** ** **
**** ** ** ** * * **** * *** * * *** * *   %d is mode\n",j);
* * ** ***** *** ****** * ** *** *** reminder=i%j;
* ** * * * *** ** * ** * * * ** * * ** (reminder == 0)
* * ** * * * ** * * * * ** ** * * * *
** * * ** ** * * * * * ******* ** * *** ** * * ** * * *** ** *** * **** * ** * *
*** * *** * * ** * *** * *** * * ** * * ** * *** * * **
** ** ** **** *** ** ** * * *** *** * * *** ** *** **** ** ** * * *
**** *** ***** *** * ** **** *** * *** * *
** *** * * ** *** *
** *** * ******* (flag==1)
* ******* * ** * ** ** **** * * * * ** * **** *** ",i);
}

return 0;
}
answered by (-141 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.17.58
©2016-2025

Related questions

0 like 0 dislike
72 answers
[Exercise] Coding (C) - asked Nov 2, 2017 in Chapter 6: Loops by semicolon (5.2k points)
ID: 29831 - Available when: 2017-11-02 18:00 - Due to: Unlimited
| 9.1k views
0 like 0 dislike
93 answers
[Exercise] Coding (C) - asked Nov 2, 2017 in Chapter 6: Loops by semicolon (5.2k points)
ID: 29830 - Available when: 2017-11-02 18:00 - Due to: Unlimited
| 10.8k views
12,783 questions
183,442 answers
172,219 comments
4,824 users