gpt4 book ai didi

C++ 两个阶乘的和等于 10 的阶乘找到两个值说 x 和 y 其阶乘总和

转载 作者:搜寻专家 更新时间:2023-10-31 00:34:55 26 4
gpt4 key购买 nike

<分区>

我被一个简单的 C++ 问题困住了,但现在这对我来说很难。谁能帮我解决这个问题。

我已经为这个问题编写了 C++ 代码,我知道代码不能作为问题的答案打印出来,但我现在不知道如何解决它。

代码如下:

#include<iostream.h>
#include<conio.h>

long int* solve10();
void main()
{
clrscr();
long int* solveten;
cout<<"Solve for ten is x factorial + y factorial equals factorial of 10"<<endl;
solveten=solve10();
cout<<"The first value is x and the second is y:"<<endl;
cout<<"The value x and the value y are:"<<endl;
for(int i=0;i<=1;i++){
cout<<*(solveten+i)<<endl;
}
getch();
}
long int* solve10(){
static long int a[2];
int k=1,x=1,l=1,y;
long int mul=1;
for(int i=1;i<=10;i++){
mul=mul*i;
}
do
{
k=x*k;
for(y=1;y<=10;y++){
l=l*y;
if((k+l)==mul){
a[0]=x;
a[1]=y;

}

}
x++;
}while(x<=10);
return a;
}

它的最佳答案是什么?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com