![]() |
請問該如何用C寫呢??
An integer is said to be prime if it is divisible by only 1 and itself. For example, 2, 3, 5, and 7 are prime, but 4, 6, 8 and 9 are not.
1. Write a function that receives a number from the main function and determines if the number is prime. 2.Write the main function that (a.)reads an integer n and uses the above function to determine and print all the prime numbers between 1 and n. (b.)calulates the sum of all prime numbers between 1 and n. A possibe run may look like: Enter the number: 10 The prime numbers between 1 and 10 are: 2 3 5 7 The sum is 17. Enter the number: 50 The prime numbers between 1 and 100 are: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 The sum is 328. 可以參考一下嗎.......... |
語法:
#include<iostream> 這句有誤,應該是The prime numbers between 1 and 50 are |
非常感謝你的解答喔!!
很詳細又有註解~~~:on_82: 我現在就來試試看.......... 感謝捏 有問題我再問你!! |
還有錯誤喔 不會吧 囧........
|
你看一下他題目要求的輸出方式
這邏輯應該無誤才對....... |
所有時間均為台北時間。現在的時間是 09:26 PM。 |
Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2025, Jelsoft Enterprises Ltd.
『服務條款』
* 有問題不知道該怎麼解決嗎?請聯絡本站的系統管理員 *