Giúp đỡ về C program

  • Thread starter Thread starter stavic
  • Ngày gửi Ngày gửi

stavic

Mega Man
Lão Làng GVN
Lời đầu em muốn gửi tới các bác là thật ra em mù tịt về khoản này, mầy cái đồ hoạ vẽ vời còn biết nhưng cái này thì chưa có thời gian nghiên cứu. Xui cái là cố gắng mấy cái code này vẫn không chạy trơn tru, biết trên này cò cao nhân nên đành xin nhờ giúp đỡ. Em không có cái gì ngoài mấy cái +rep cùi, nhưng thật tình rất mong các bác giúp em qua hết con trăng này :((

Đây là câu hỏi
Write *one* C program that will accomplish *all* the following steps:

1) Display the complete Fibonacci sequence until you reach a value less or equal than
1,000,000 (one million).

2) Display the count of how many numbers are in that sequence between 1 and 1,000,000.

3) Display (or emphasize in the display of step #1) all the numbers (if any) that are part of
the Fibonacci sequence below 1,000,000 and whose square root is a whole number. For example 16
has a whole square root (4), but 16 is not part of the Fibonacci sequence.

4) Display (count) how many numbers satisfy the two conditions indicated in step #3 (part of
Fibonacci below 1,000,000 and whole square root).

5) Starting with the second number of the sequence, display the division of the number by the
previous one for the complete sequence (4 decimals precision). Can you see a pattern developing?
We call this the Golden Number.
Còn đây là cái em code
#include <stdio.h>
#include <math.h>

int a=0, c, count=1;
double b=1, d;

int main(void)
{
printf("1\n");
for (b=1; b<1000000; c++)
b=a+b;
a=b-a;
b=a+b-a;

if(b<1000000)
count= count + 1;
printf("%lf\n",b);



while (b<1000000) {

}
}
d=sqrt(b);
if (floor(d)- d==0) {
printf("%1.lf has a square root of %lf",b,d);
b=a+c;
a=c;
c=b;

if ((d=sqrt(b))) {
printf("%lf", b);
} }




printf("There are %d numbers\n", count);

return 0;
Nhưng vì sai ở mấy dòng nó vẫn chưa chạy được, mà em đang chạy ngược thời gian tại nay đi làm về trễ ko kịp làm bài :( Mong các tiền bối giúp đỡ
 
Back
Top