//第一题
#include
#include
using namespace std;
bool prime (int m);
int changP(int m);
int main(int argc, char* argv[])
{
for (int i=10; i<100; ++i)
{
if (prime(i))
{
changP(i);
if (prime(i))
{
cout<}
}
}
cout<
return EXIT_SUCCESS;
}
bool prime (int m)
{
int r = sqrt (m);
for (int i = 2; i <= r; i++)
if (m % i == 0)
return false;
return true;
}
int changP(int m)
{
m = (m%10)*10 + m/10;
return m;
}
//第二题
#include
#include
using namespace std;
void LeastCommonMultiply(int m, int n, int b);
int GreatestCommonDivisor(int m, int n);
int main(int argc, char* argv[])
{
int m = 0, n = 0;
cout<<"请输入两个整数: \b";
cin >> m >> n;
int b = GreatestCommonDivisor(m,n);
LeastCommonMultiply(m, n, b);
system("pause");
return EXIT_SUCCESS;
}
int GreatestCommonDivisor(int m, int n)
{
int a = (m > n) ? m : n;
int b = (m > n) ? n : m;
int c = 0;
while ((a % b) != 0)
{
c = a % b;
a = b;
b = c;
}
return b;
}
//求最小公倍数
void LeastCommonMultiply(int m, int n, int b)
{
//两数相乘再除以最小公倍数
cout << m << "和" << n << "的最大公约数 = " << b << endl;
cout << m << "和" << n << "的最小公倍数 = " << m * n / b << endl;
}
//第三题
#include
#include
using namespace std;
int main()
{
int a,b,c,t;
double x1,x2;
cout<<"a,b,c的值:";
cin>>a>>b>>c;
t=b*b-4*a*c;
if(t>=0)
x1=(-b+sqrt(t))/(2*a);
x2=(-b-sqrt(t))/(2*a);
cout<<"x1="<
cout<<"该方程无解!"<
}
//第四题
麻烦你再清楚一点:Cm-1 + Cm-1 n>1 看不懂
//========第一题================
#include
#include
using namespace std;
bool prime (int m);
int changP(int m);
int main(int argc, char* argv[])
{
for (int i=10; i<100; ++i)
{
if (prime(i))
{
changP(i);
if (prime(i))
{
cout< }
}
}
cout<
return EXIT_SUCCESS;
}
bool prime (int m)
{
int r = sqrt (m);
for (int i = 2; i <= r; i++)
if (m % i == 0)
return false;
return true;
}
int changP(int m)
{
m = (m%10)*10 + m/10;
return m;
}
//第二题==========================
#include
#include
using namespace std;
void LeastCommonMultiply(int m, int n, int b);
int GreatestCommonDivisor(int m, int n);
int main(int argc, char* argv[])
{
int m = 0, n = 0;
cout<<"请输入两个整数: \b";
cin >> m >> n;
int b = GreatestCommonDivisor(m,n);
LeastCommonMultiply(m, n, b);
system("pause");
return EXIT_SUCCESS;
}
int GreatestCommonDivisor(int m, int n)
{
int a = (m > n) ? m : n;
int b = (m > n) ? n : m;
int c = 0;
while ((a % b) != 0)
{
c = a % b;
a = b;
b = c;
}
return b;
}
//求最小公倍数
void LeastCommonMultiply(int m, int n, int b)
{
//两数相乘再除以最小公倍数
cout << m << "和" << n << "的最大公约数 = " << b << endl;
cout << m << "和" << n << "的最小公倍数 = " << m * n / b << endl;
}
后面两题我不会做了.
123题都不难,第4题看不懂