#include <iostream>
using namespace std;
int main(){
int a,b,hcf=0,i=1;
cout<<"Enter Value :";
cin>>a;
cout<<"Enter value :";
cin>>b;
while(i<=a || i<=b){
if(a%i ==0 && b%i ==0)hcf=i;
++i;
}
return 0;
}
還是剩餘方法?這是找到hcf的好方法嗎?
請格式化您的代碼 – 2011-01-26 16:40:16
我無法弄清楚您正在嘗試做什麼,或者hcf並不意味着「最高公因子」?代碼中做了什麼? – 2011-01-26 16:42:56