0 like 0 dislike
4.2k views
請設計一個程式,讓使用者輸入兩個正整數a以及b(a <= b),從小到大輸出a到b之間的所有質數。

範例輸入:

1 10

範例輸出:

2 3 5 7
[Exercise] Coding (C) - asked in 作業 by (18k points)
ID: 13617 - Available when: Unlimited - Due to: Unlimited
| 4.2k views
0 0
Called for Help
0 0
Called for Help
0 0
Called for Help

91 Answers

0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main()

{
** * * ** ** * *** * x=0,y=0,j,k;
* ** * * * ** ** * *** * ***** ** * *
**** * * * * * * = x;j <= y;j++)
** **** * *
* ** * ** ** * * **** ** *** * * k<j ; k++)
* * * ************* ** ** * ***** * **
** * ** *** * **** * ***** *** ** ** * ** * ** % k == 0)
***** * * *** *** *** ** * *** ** ** **** *** * *
** ***** ** * * * ***** *** ***
** * ** ***** **** * * * *** == j)
* * ** * * * ***** * ** **** * * ***** **** ",j);
* * *** *** ** * * *

}
answered by (-162 points)
0 like 0 dislike
Hidden content!
* * ****** **
* ** ***** *** **



int main ** ***

{
*** * *


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


* ******* **

{
** * ** *

{


* * * % d == **



}




** == d ** **** ** * ** ** **** * * *** * ***



}




* 0;

}
answered by (-276 points)
0 like 0 dislike
Hidden content!
* **** * * ** ** *



int main()



{
* * ******* *** a, b, j, k;
** ***** * * *** * * **** ***** ** * * ** *
** * * ** ** * ** = a ; j * * b; j ++)
* ** ***
* ** * * * = 2;k ** j;k ++)
** * * * **** *
****** ***** * * * j % k ==0)
* * *** * * **
*** * * *** *
***** * == j)
* * * ** * * * ** *
**




** ** * * ****** 0;
answered by (-24 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<stdlib.h>



int main()

{
* * *** *** ** * *** * a, b, j, k;
**** * ** **** * *** *** * ** ** * ***** &a, &b);


** * **** * * * * = a; j <= b; j++)
* * ** * ** * *** * ***
* *** ** ***** * ** ** * * ** * * = 2; k < j; k++)
* **** ** ** ** ** * * * * ***** ** * *
**** *** * * * * * * * * *** * **** * * ** ***** **** * **** % k == 0)
*** * ** **** ** ** * *** * * * * ** *** ******* *** ** **** *** * * **** *** * * *** *
* ** * * * * * * *** ** * * * ** ** * ** *
* * * ** * ** * **** *** * ****** * == j)
** * * ** *** ** ** ****** * * ****** * ** *** *** * *** * **
** * * ** ***** ** * * * ** * **** ** ** *** * * * * * * * * *** *** ** ** ** *** ** * *** ** ** ", j);
**** ** * * * ** ** ** ** ** * ** * ** * ** * * **

    }



return 0;

}
answered by (-105 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>



int main() {

    
* * * ** * **** a=0;

    int b=0;

    int i,j;

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


** * *** ** **** * ** * ** ** * ***
* ** * ******** * ** * *** * ** * **
*** * * * * * ** * ** * * * ** * ** * ** * * *
* * * ******* ** * * * * * ** ** ** **** ** * * ** * * ** * ******** * ** i%j == 0 ){
******** * * ** *** **** ** ** *** * ** * * ** ** * * ** * **** **** ** **** ** * * * * **
* ** * *** * * ** *** * *** ** *** ** ** *** ** ***
* * ** * * * * * * *** * * ******* ** ** * ****
** ** ** * * * *** ** ***** * * ***** *** ** * * *** ***
* **** * ******** ** ***** * *** * * ** ** **** * * ** * * ** ** * *** ** ** ******* ",j);
** * * * ** * * * * * * ***** *

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

}
answered by (-126 points)
0 like 0 dislike
Hidden content!
* * * ** * **



int main()



{
* ** * * **** a, b, j, k;
** **** ** * * ** * * ** ** * * **
**** ** ** ***** = a ; j ** b; j ++)
* ** ** *
**** * *** = 2;k j;k ++)
* ** * *** *
** ** * * * * * j % k ==0)
* * **** ****
* **** * ***
* * ** == j)
* *** *** **** * j);
**




* * * * * *** * 0;

}
answered by (-24 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>



int main() {

    
* ** * * ******** * * a=0;
**** ** * ** *** *** b=0;

    int i,j;

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


** ** ****** ** *** ** ***** * *
**** ** ** ** ***** ** * *** ** *
* * * **** ** **** * ** **** ** * ** * * * ** *
**** ***** * ** * * * *** * * ****** ** ** * * **** * **** * * * ** * i%j == 0 ){
* ** * * ** * *** *** **** * *** * ** * * * *** * ** *** **** * * ** * ** *
**** **** * * * *** * * ** * * ** ** * * * **** * ** * * * **
* ***** **** * **** ** *** * ***** * ** *
* * *** * ** *** ** ** ** ** ***** * * ** * * *** *
*** * ** *** * ** ** *** ** **** ** * * *** * * * ** * *** * * ** * * ** ",j);
*** * * ** * * * *** **** * ***** * *

    }

    


** ** ** ** * * * * * ** 0;
answered by (-126 points)
0 like 0 dislike
Hidden content!
* ** ** * **



int main()



{
** ** ** * a, b, j, k;
* ** *** ** **** * **** * **** * * ** *
* ** ** * = a ; j * b; j ++)
**** *** * **
*** ** * ******* * = 2;k * * j;k ++)
**** * *
*** ** ** ***** **** j % k ==0)
* * * ** * ** * **
** * ****
** * * == j)
* * * ** * * * * ** j);
* *




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

}
answered by (-24 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main()

{
* ** * *** * ***** * num1= 0,num2=0 ,k ,wh = 0 ;
* ******** **** * * ****** ** * * *
* ** ** * ** * *** **** **** *
****** ** ** * (num1 <= num2)
* ** * * * ****
* ** * ** ** * *** * *** * (k=2 ; k<num1 ; k++)
* **** ****** * * ** * * *** ***
** ** * * ******* *** * **** ** * *** ** *** *** ** * (num1%k == 0)
* ** ** * *** ** *** * ** ******* * * * *** * * * *** * ****


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


** * * * ** ** * ******* * ** **** * (wh == 0 && num1 > 1)
*** * * * * * * ** ** * ******** * * * **** ** ",num1);


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


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



}
answered by (-122 points)
0 like 0 dislike
Hidden content!
#include ** ** *

int main()

{
*** * * * * n , j ,k = 0;
**** * * * ****** * ** * * *******


**** **** * (j = 2;j < n; j ++)
* * *
* ** ** *** *** ******** * ** % j == 0)
* * * * * * * * *** *
* * * ****** *** * ** ** ***** ** ** *** * ** = 1;
* * **** ** **** * ****** ****** **** * ** *** ** * * ******* ",j);


* **** ** * *** * * ****
***** *
* * * (k == 0 * * * * * * n > 1)
* * ** * * * **** * ** * * * ** ** a prime");


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

}
answered by (43 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.130.236
©2016-2024

Related questions

0 like 0 dislike
64 answers
[Exercise] Coding (C) - asked Oct 13, 2016 in 作業 by Shun-Po (18k points)
ID: 13763 - Available when: Unlimited - Due to: Unlimited
| 2.8k views
0 like 0 dislike
61 answers
[Exercise] Coding (C) - asked Oct 13, 2016 in 作業 by Shun-Po (18k points)
ID: 13736 - Available when: Unlimited - Due to: Unlimited
| 3.1k views
0 like 0 dislike
117 answers
[Exercise] Coding (C) - asked Oct 13, 2016 in 作業 by Shun-Po (18k points)
ID: 13581 - Available when: Unlimited - Due to: Unlimited
| 4.9k views
1 like 0 dislike
48 answers
[Exercise] Essay (Open question) - asked Nov 2, 2016 in 作業 by Shun-Po (18k points)
ID: 16865 - Available when: Unlimited - Due to: Unlimited
| 2.6k views
0 like 0 dislike
76 answers
[Exercise] Coding (C) - asked Oct 19, 2016 in 作業 by Shun-Po (18k points)
ID: 14120 - Available when: Unlimited - Due to: Unlimited
| 3.5k views
12,783 questions
183,443 answers
172,219 comments
4,824 users