mn算法
1. 涓阆撴暟瀛﹁В鏂圭▼锛屾眰瑙mn绛変簬澶氩皯锛岃佸啓杩囩▼锛
鎭ㄥソ锛岃繖涓棰樼洰鍐椤湪杩欎釜绾稿眬浜涓婅佽厞婕忎简锛岃佺敤鍒伴茕杈惧畾鐞嗘潵渚岖儌瑙d竴鍏冧簩娆℃柟绋嬶纴M,N 涓や釜鏁板垎鍒鐢ㄤ唬鍏ユ秷鍏冩硶锛岃缮链変笁瑙掑嚱鏁扮殑绠楁硶锛岃繖涓棰樼洰瀵逛簬鍒濅腑鐢熸潵璇达纴缁煎悎镐ц缮鏄链変竴浜涚殑銆
2. 杈揿叆鏁存暟mn姹傛渶澶у叕绾︽暟鍜屾渶灏忓叕鍊嶆暟
涓嬮溃鐢ㄥ埌镄勬柟娉曞彨杈楄浆鐩搁櫎娉曪纴鍏峰仛姝ラゅ备笅
鍏堢敤灏忕殑涓涓鏁伴櫎澶х殑涓涓鏁帮纴寰楃涓涓浣欐暟锛
鍐岖敤绗涓涓浣欐暟闄ゅ皬镄勪竴涓鏁帮纴寰楃浜屼釜浣欐暟锛
鍙堢敤绗浜屼釜浣欐暟闄ょ涓涓浣欐暟锛屽缑涓惧仛琛$涓変釜浣欐暟锛
杩欐牱阃愭$敤钖庝竴涓鏁板幓闄ゅ墠涓涓浣欐暟锛岀洿鍒颁綑鏁版槸0涓烘銆傞偅涔堬纴链钖庝竴涓闄ゆ暟灏辨槸镓姹傜殑链澶у叕绾︽暟锛埚傛灉链钖庣殑闄ゆ暟鏄1锛岄偅涔埚师𨱒ョ殑涓や釜鏁版槸浜掕川鏁帮级銆
鐢–璇瑷锛
#include <stdio.h>
main()
{
int p,r,n,m,temp;
printf("璇疯緭鍏ヤ袱涓姝f暣鏁皀,m"); //杩欎釜鍦版柟杩愭e仛琛屾椂瑕佹敞镒忥纴涓や釜鏁板瓧涔嬮棿瑕佺敤钬滐纴钬濆壊寮銆
scanf("%d,%d"鑳℃簮,&n,&m);
p=n*m;
if(n<m)
{temp=n;
n=m;
m=temp;
}
while(m!=0)
{
r=n%m;
n=m;
m=r;
}
printf("瀹冧滑镄勬渶澶у叕绾︽暟涓猴细%d\n",n);
printf("浠栦滑镄勬渶灏忓叕鍊嶆暟涓猴细%d\n",p/n);
}