2 like 0 dislike
258 views

設計一個樂透號碼產生程式。首先定義結構 Lotto,裡面包含兩個成員:iNumber為該球的編號,iValue 為該球出現的次數。並以 typedef 的方式將 Lotto 重新命名為 LUCKY,並以 LUCKY 在主程式中宣告結構陣列 lucky[42],也就是樂透球的號碼是編號 1 到 42 號。號碼的產生方式為:先以讓使用者輸入要亂數值行的次數,介於 10000 到 100000 之間。然後以亂數產生器執行指定的次數,每次都是隨機產生 1 到 42 號,產生的號碼就在相對應樂透球的 iValue 上加 1,代表該號碼球出現一次。最後根據每一顆球的 iValue 值加以排序,選出 iValue 值最高的前七位,該七顆球的號碼就是當期的號碼。

 

參考書籍:旗標無痛學習教本

[Normal] Essay (Open question) - asked in Introduction to Computer Programming I (C) by (20.9k points)
ID: 21900 - Available when: Unlimited - Due to: Unlimited
| 258 views
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.100.166
©2016-2024

Related questions

2 like 0 dislike
0 answers
[Normal] Essay (Open question) - asked Feb 11, 2017 in Introduction to Computer Programming I (C) by The Contributor (20.9k points)
ID: 21899 - Available when: Unlimited - Due to: Unlimited
| 231 views
1 like 0 dislike
0 answers
[Normal] Essay (Open question) - asked Feb 11, 2017 in Introduction to Computer Programming I (C) by The Contributor (20.9k points)
ID: 21898 - Available when: Unlimited - Due to: Unlimited
| 263 views
2 like 0 dislike
0 answers
[Normal] Essay (Open question) - asked Feb 11, 2017 in Introduction to Computer Programming I (C) by The Contributor (20.9k points)
ID: 21897 - Available when: Unlimited - Due to: Unlimited
| 323 views
2 like 0 dislike
0 answers
[Normal] Essay (Open question) - asked Feb 11, 2017 in Introduction to Computer Programming I (C) by The Contributor (20.9k points)
ID: 21896 - Available when: Unlimited - Due to: Unlimited
| 251 views
3 like 0 dislike
0 answers
[Normal] Essay (Open question) - asked Feb 19, 2017 in Introduction to Computer Programming I (C) by The Contributor (20.9k points)
ID: 21943 - Available when: Unlimited - Due to: Unlimited
| 268 views
12,783 questions
183,443 answers
172,219 comments
4,824 users