Main Page | Chinese News | English News | Reviews | Forum | UK Price List | US Price List | Links | History | Contact | Privacy | Site Map

Custom Search


Go Back   OCWorkbench Lifestyle and Tech Forums > 中文區 > 處理器/主機板/顯示卡/記憶體

處理器/主機板/顯示卡/記憶體 討論最新的處理器/主機板/顯示卡/記憶體

Click here to resend forum activation email
Lost your password, Request it here


程式設計論壇之1--最大公因數與質因數分解

處理器/主機板/顯示卡/記憶體


Reply
Add this thread to:  Submit to Clesto Clesto  Submit to Digg Digg  Submit to Reddit Reddit  Submit to Furl Furl  Submit to Del.icio.us Del.icio.us  Submit to Spurl Spurl
 
Thread Tools
  #1  
Old 28-11-2003, 04:09 AM
xmansean xmansean is offline
Member
 
Join Date: Jul 2003
Location: Kaohsiung,Taiwan
Posts: 216
Potenza rep: 0
xmansean is an unknown quantity at this point
Post

請問各位先進:
在c++中

1.如何寫出求兩個輸入的數a,b的最大公因數(Greatest common factor)?

2.如何質因數分解一個數?ex:將1200分解成(2^4)*3*(5^2)

請各位幫幫忙吧,因為我快想破頭了 :(
Reply With Quote
  #2  
Old 28-11-2003, 04:13 AM
WUYI WUYI is offline
BANNED Troublemakers
 
Join Date: Oct 2001
Location: Beijing,China
Posts: 599
Potenza rep: 0
WUYI is an unknown quantity at this point
Post

你这个家伙,要么不来,来了就没好事,要害的大家都想破脑袋才罢休 :D
Reply With Quote
OCWorkbench
  #3  
Old 28-11-2003, 04:21 AM
bluetooth bluetooth is offline
The one
 
Join Date: May 2000
Location: UK
Posts: 97,352
Potenza rep: 10
bluetooth has disabled reputation
Post

http://www.math.com/school/subject1/.../S1U3L2GL.html
Reply With Quote
  #4  
Old 28-11-2003, 04:24 AM
WUYI WUYI is offline
BANNED Troublemakers
 
Join Date: Oct 2001
Location: Beijing,China
Posts: 599
Potenza rep: 0
WUYI is an unknown quantity at this point
BT找的链接,看看~~http://www.math.com/school/subject1/.../S1U3L2GL.html
Reply With Quote
  #5  
Old 28-11-2003, 04:29 AM
WUYI WUYI is offline
BANNED Troublemakers
 
Join Date: Oct 2001
Location: Beijing,China
Posts: 599
Potenza rep: 0
WUYI is an unknown quantity at this point
Post

又是BT找的,看: http://amby.com/educate/math/2-1_GCF.html
Reply With Quote
  #6  
Old 28-11-2003, 06:58 AM
xmansean xmansean is offline
Member
 
Join Date: Jul 2003
Location: Kaohsiung,Taiwan
Posts: 216
Potenza rep: 0
xmansean is an unknown quantity at this point
Post

這.......定義我是知道啦,問題是要用什麼函式寫出來呢?(用c語言)
Reply With Quote
  #7  
Old 28-11-2003, 07:01 AM
xmansean xmansean is offline
Member
 
Join Date: Jul 2003
Location: Kaohsiung,Taiwan
Posts: 216
Potenza rep: 0
xmansean is an unknown quantity at this point
Post

Quote:
Originally posted by WUYI:
你这个家伙,要么不来,来了就没好事,要害的大家都想破脑袋才罢休 :D
基本上....我頭已經爆了.....
Reply With Quote
  #8  
Old 28-11-2003, 02:10 PM
Marx1977 Marx1977 is offline
Junior Member
 
Join Date: Sep 2003
Location: taiwan
Posts: 33
Potenza rep: 0
Marx1977 is an unknown quantity at this point
lcd(m1,m2)
m1是大數,m2是小數......將m1/m2求得之餘數...在與m2相除.....如此recursive下去...當某次的餘數為零...則此除數為最大公因數!!
Reply With Quote
  #9  
Old 28-11-2003, 08:11 PM
xmansean xmansean is offline
Member
 
Join Date: Jul 2003
Location: Kaohsiung,Taiwan
Posts: 216
Potenza rep: 0
xmansean is an unknown quantity at this point
所以說只要用個迴圈一直除....除到於數等於0之後,找上一個除數cout出來就可以了吧?
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


(C) Copyright OCWORKBENCH 1998-2011
All times are GMT +8. The time now is 11:18 AM.


Copyright OCWORKBENCH 1998-2013 Singapore, Malaysia, Thailand, Philippines, Indonesia, China, Taiwan, USA, UK