#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int k=1,j2=0,j1=0,j=0,g=0,u=0,;
cout<<"英數計算器"<<endl;
cout<<"輸入一個數值"<<endl;
cin>>j;
cout<<"輸入一個數值"<<endl;
cin>>j1;
cout<<"輸入一個數值"<<endl;
cin>>j2;
while (k<=j)
{
if(j%k==0&&j1%k==0&&j2%k==0)
{
cout<<k<<","<<endl;
g++;
u=k+u;
}
k++;
}
cout<<"有"<<g<<"個因數"<<endl;
cout<<"總合為"<<u<<endl;
system("pause");
return 0;
} |