C程序搜索不在斐波那契序列中的数字
我需要帮助用C编程语言编写simple程序,帮助用户搜索给定整数范围的斐波那契序列中的整数而不是。 我有一个程序,以给定的顺序显示斐波那契数,以供参考C程序搜索不在斐波那契序列中的数字,c,fibonacci,C,Fibonacci,我需要帮助用C编程语言编写simple程序,帮助用户搜索给定整数范围的斐波那契序列中的整数而不是。 我有一个程序,以给定的顺序显示斐波那契数,以供参考 int main() { int i; /* Declare and initialise an int array with the first 2 fibonacci numbers 1 and 1 */ /* The size of the array should be NUM_FIBON. */ int *fibonacci; int
int main()
{
int i;
/* Declare and initialise an int array with the first 2 fibonacci numbers 1 and 1 */
/* The size of the array should be NUM_FIBON. */
int *fibonacci;
int sizeOfArray;
/* Display the purpose of the program */
printf("\nThis program displays the fibonacci numbers\n\n");
printf("Enter the number of Fibonacci numbers to compute: ");
scanf("%i", &sizeOfArray);
fibonacci = malloc(sizeof(int) * sizeOfArray);
fibonacci[0]=1;
fibonacci[1]=1;
/* Populate the array with other fibonacci numbers, starting with the 3rd number */
/* Each fibonacci number is the sum of the previous two */
for(i=2; i<sizeOfArray; i++)
{
fibonacci[i] = fibonacci[i-1]+fibonacci[i-2];
}
/* Print message:
* Calculation over.
* Press [Enter] to display the first x fibonacci numbers
*
* then wait for the [Enter] key to be pressed.
*/
printf("Calculation over \nPress ENTER to display the first %i fibonacci numbers\n\n", sizeOfArray);
getch();
/* Print the 12 first fibonacci numbers */
for(i=0; i<sizeOfArray; i++)
{
if (i % 10 == 0)
{
printf("\n");
printf("%-8i", fibonacci[i]);
}
else
{
printf("%-8i", fibonacci[i]);
}
}
free(fibonacci);
/* Pause so the result can be seen when the program starts from windows explorer */
getch();
/* Return success code to the operating system */
return 0;
intmain()
{
int i;
/*声明并初始化具有前2个斐波那契数1和1的整数数组*/
/*数组的大小应为NUM_FIBON*/
int*斐波那契;
int-sizeOfArray;
/*显示程序的目的*/
printf(“\n此程序显示斐波那契数\n\n”);
printf(“输入要计算的斐波那契数:”);
scanf(“%i”和“sizeOfArray”);
斐波那契=malloc(sizeof(int)*sizeOfArray);
斐波那契[0]=1;
斐波那契[1]=1;
/*用其他斐波那契数填充数组,从第三个数开始*/
/*每个斐波那契数都是前两个数的和*/
对于(i=2;i是的,这段代码有点像是在转移视线。你需要一个名为is_fibbonacci的函数,1个参数为int,返回TRUE或FALSE。在while循环中,你只需要3个变量就可以计算下一个fibbonacci,直到下一个大于或等于参数。步骤1:重写fibbonacci生成器,使其正常工作,现在需要1个参数r步进并返回fib数。因此0返回1,1返回2,2,3等。
步骤2:复制新的fibbonacci生成器,重命名为\u fibbonacci。重命名参数以测试\u值。
在循环while(test_value问题是什么?也许有帮助。你能帮我编码吗?用我写的代码,我可以生成斐波那契数,但我需要一个程序生成不在斐波那契序列中的数。你能帮我解决实际的代码吗?我完全不懂这件事。你的电子邮件是什么,我需要在邮寄listingsaad.zafar之前,使用笔记本电脑进行编译和测试。7223@live.comHey,我可能会在上面修改我的电子邮件地址。另外,请发布我发给你的代码,其他人也会得到帮助。